Skip to content

Instantly share code, notes, and snippets.

Emre Goren emregoren

Block or report user

Report or block emregoren

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View encode
fun encodeImage(bm: Bitmap): String? {
val baos = ByteArrayOutputStream()
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos)
val b = baos.toByteArray()
return Base64.encodeToString(b, Base64.DEFAULT)
}
fun decodeImage(bm: String, imageView: ImageView,resources: Resources) {
val imageBytes = Base64.decode(bm, Base64.DEFAULT)
val decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
View higher-order function default
fun printUserInfo(name: String, getSurName: (surName: String) -> String = { "" }, age: Int): Unit {
}
View higher-order function cagrimi
fun main() {
val higherOrderFunction = { surName: String -> "surName : $surName" }
val anonymousFunction = fun(surName: String): String { return "surName : $surName" }
printUserInfo("EMRE", higherOrderFunction, 20)
printUserInfo("EMRE", anonymousFunction, 20)
printUserInfo("EMRE", fun(surName: String): String {
return "surName : $surName"
}, 20)
View anonymous higher-order function
val anonymousFunction = fun(surName: String): String { return "surName : $surName" }
View state higher-order
val higherOrderFunction = { surName: String -> "surName : $surName" }
View class extension function
fun main() {
val test = Test()
test.main()
}
class Test {
fun main() {
3 topla 5
}
View infix extension function
fun main() {
3 topla 5
}
infix fun Int.topla(sayi: Int) {
return println(this + sayi)// this =3 , sayi=5
}
View extension function
fun main() {
3.topla(5)
}
fun Int.topla(sayi: Int) {
return println(this + sayi)// this =3 , sayi=5
}
View infix function
fun main() {
val test = Test()
test ekranaYaz "selam"
}
class Test {
infix fun ekranaYaz(metin: String) {
return print(metin)
}
}
View varargs
fun main() {
getUserInfo("1", "2", "3", "4", key = 22)
}
fun getUserInfo(vararg userInfo: String, key: Int) {
userInfo[3]
userInfo.get(3)
}
You can’t perform that action at this time.