Skip to content

Instantly share code, notes, and snippets.

View sajjadyousefnia's full-sized avatar
🤒
Out sick

Sajjad Yousefnia sajjadyousefnia

🤒
Out sick
View GitHub Profile
with(webview.settings) {
javaScriptEnabled = true
databaseEnabled = true
}
// similarly
webview.settings.run {
javaScriptEnabled = true
databaseEnabled = true
// Yack!
with(webview.settings) {
this?.javaScriptEnabled = true
this?.databaseEnabled = true
}
}
// Nice.
webview.settings?.run {
javaScriptEnabled = true
fun test() {
var mood = "I am sad"
run {
val mood = "I am happy"
println(mood) // I am happy
}
println(mood) // I am sad
}
run {
if (firstTimeView) introView else normalView
}.show()
stringVariable?.run {
println("The length of this String is $length")
}
// Similarly.
stringVariable?.let {
println("The length of this String is ${it.length}")
}
/* Java */
package com.chikekotlin.projectx.utils
public class UserUtilsKt {
public static String checkUserStatus() {
return "online";
}
}
/* Java */
import com.chikekotlin.projectx.utils.UserUtilsKt
...
UserUtilsKt.checkUserStatus()
@file:JvmName("UserUtils")
package com.chikekotlin.projectx.utils
fun checkUserStatus(): String {
return "online"
}
/* Java */
import com.chikekotlin.projectx.utils.UserUtils
...
UserUtils.checkUserStatus()
val message = { println("Hey, Kotlin is really cool!") }
message() // "Hey, Kotlin is really cool!"