Skip to content

Instantly share code, notes, and snippets.

View ehsansouri23's full-sized avatar
๐Ÿ˜ƒ
Just Hope :)

Ehsan Souri ehsansouri23

๐Ÿ˜ƒ
Just Hope :)
View GitHub Profile
@ehsansouri23
ehsansouri23 / sample.py
Created October 4, 2018 13:02
a sample gist in github
print("this is a sample code in python")
interface DisplayManager {
fun showText(text:String)
}
@ehsansouri23
ehsansouri23 / .kt
Created December 30, 2021 10:03
using With Kotlin function
data class User(
val firstName:String,
val lastName:String,
val address:Address
)
// using `with` function
val user = User()
with(user) {
println(firstName)
println(lastName)
@ehsansouri23
ehsansouri23 / .kt
Created December 30, 2021 10:10
Kotlin null checking with let function
val address = findAddress()
address?.let {
println("$it is a valid address")
} ?: run {
println("address was null)
}
@ehsansouri23
ehsansouri23 / .kt
Created December 30, 2021 10:16
Kotlin apply function
val user = User().apply {
firstName = "ehsan"
lastName = "souri"
address = Address()
}