vishna
12/03/2018, 5:13 PMmark
12/03/2018, 8:31 PMDavio
12/04/2018, 9:41 AMinline fun <reified T> calc(p: String): T? {
return if (null is T) {
println("nullable")
null
} else {
println("not nullable")
"foo" as T?
}
}
fun main() {
calc<String?>("hello")
calc<String>("hello")
}
elect
12/04/2018, 9:48 AMval
inside `object`s are translated in java as private
, while const val
are public
.. why?Bernhard
12/04/2018, 12:43 PMziggy42
12/04/2018, 1:15 PMD
kartikpatodi
12/04/2018, 1:31 PMheruan
12/04/2018, 2:18 PMTasos Stamadianos
12/04/2018, 4:18 PMCasey Kulm
12/04/2018, 5:19 PMDavio
12/04/2018, 6:06 PMkarelpeeters
12/04/2018, 6:30 PMfitzoh
12/04/2018, 8:10 PM`in`.doSomething()
? 😆dknapp
12/04/2018, 8:12 PMDavio
12/05/2018, 8:38 AMit
?arve
12/05/2018, 9:46 AMpackage somePkg
interface MyInterface {
fun myFun(): MyType
data class MyType
}
I don't want to pollute somePkg
with MyType
, since it's pretty specific to the domain of MyInterface
, and there is other stuff in the same package. Are there any pitfalls to defining a data class inside an interface that I should be aware of? What about putting it inside companion object inside the interface? Is the only difference in the import statement you have to use?Ayoub
12/05/2018, 11:59 AMkarelpeeters
12/05/2018, 2:44 PMfun IntRange.clamp(value: Int) = when {
value <= start -> start
value >= endInclusive -> endInclusive
else -> value
}
Tsvetozar Bonev
12/05/2018, 3:01 PMAlan Evans
12/05/2018, 3:02 PMAndrew Gazelka
12/05/2018, 4:47 PMcheck()
for private method logic errors?Casey Brooks
12/05/2018, 5:25 PMdata class Document(
val _resourceId: String
) : Resource {
override fun getResourceId() = _resourceId
}
Hullaballoonatic
12/05/2018, 9:06 PMthrows
extension to methods and classes that java does whenever anything they contain will throw one?Icaro Temponi
12/05/2018, 11:15 PMMarcin Wisniowski
12/06/2018, 2:07 AMjoinToString(", ")
to construct a comma separated string from a list of names. What would be an idiomatic way to make the last comma an "and" instead? I am getting "a, b, c, d", but want to get "a, b, c and d". I can replace it afterwards, or join all the names except the last one and add it separately, but maybe someone here has an elegant solution I'm not seeing?
This is the best I can currently think of:
names.dropLast(1).joinToString(", ") + " and " + names.last()
spand
12/06/2018, 9:06 AMisInitialized
on a local variable (ie. not property) lateinit var
? If so what is the syntaxTsvetozar Bonev
12/06/2018, 1:23 PMJonathan
12/06/2018, 4:15 PMRohan Maity
12/06/2018, 4:30 PM