Skip to content

Instantly share code, notes, and snippets.

shruti-basil-hs

Block or report user

Report or block shruti-basil-hs

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 Java-FindViewById
textView  = (TextView) findViewById(R.id.text_foo);
textView.setText(“foo”);
View Extension-functions
View.visible() {
this.visibility = View.Visible
}
View with-example
val w = Window()
with(w) {
setWidth(100)
setHeight(200)
setBackground(RED)
}
View with-func-definition
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
View apply-example
Person(name).apply { foo() };
//Equivalent 4 line Java code
Person getFoo(String name) {
Person person = new Person(name);
person.foo();
return person;
}
View apply-func-description
fun <T> T.apply(f: T.() -> Unit): T { f(); return this }
View let-example
Person.getName().let { name ->
print(name)
}
// name is no longer visible here
View KotlinNullSafety
class Person(var name: String?) // the name property can be null
class Person(var name: String) // the name property cannot be null
You can’t perform that action at this time.