Andrew Gazelka
05/14/2019, 9:45 PM==
?Andrew Gazelka
05/14/2019, 10:02 PMInteger
for lateinit num: Int
iex
05/14/2019, 11:39 PMMyObj ( var1 ?: return null, var2 ?: return null)
not sure that's ideal thoughAndrew Gazelka
05/15/2019, 1:15 AMDavid Stolarsky
05/15/2019, 4:56 AMKulwinder Singh
05/15/2019, 5:08 AMsortedBy
function is throwing Null pointer even if my List type is not nullablegregorbg
05/15/2019, 6:45 AMRok Koncina
05/15/2019, 9:58 AMval list = mutableListOf<Item>()
.apply {
add(getItem())
addAll(getMultipleItems())
add(getItem())
}
fun getItem() = Item()
fun getMultipleItems() = listOf(Item(), Item(), Item())
☝️ this is the closest I've gotAndrew Gazelka
05/15/2019, 10:02 AMAndrew Gazelka#0001
Discord.Andrew Gazelka
05/15/2019, 10:11 AMiex
05/15/2019, 3:19 PMclass A {
val foo = "hello"
}
class B(a: A) {
init {
a.foo.bar // null pointer
}
}
`
karelpeeters
05/15/2019, 4:25 PMclass Action(val field1: String, val field2: String, closure: Action.() -> Unit) {
private val _closure = closure
val closure: () -> Unit = { this._closure() }
}
val myAction = Action("value1", "value2") { callAnotherFunctionHere(this) }
Hullaballoonatic
05/16/2019, 5:09 AMAndrew Gazelka
05/16/2019, 11:18 AMJoffrey
05/16/2019, 1:13 PM==
is less permissive than its method counterpart equals()
?
The compiler doesn't seem to accept 'c' == "string"
, but it does accept 'c'.equals("string")
.
Isn't it supposed to be the same code? In IntelliJ IDEA, when Ctrl+clicking ==
, it brings me to the same definition as `equals()`:
public open operator fun equals(other: Any?): Boolean
This is supposed to accept Any?
. Did the Kotlin team keep this equals()
signature for easier Java interop? In this case, is the inconsistency with ==
intended in order to provide more type safety?lynas
05/16/2019, 2:23 PMkevinherron
05/16/2019, 3:06 PMiex
05/16/2019, 6:47 PMout E
is where I started. See first snippetiex
05/16/2019, 7:36 PMiex
05/16/2019, 7:36 PMval closure = { (a: Int -> Int) ->
a * 2
}
Robert
05/16/2019, 7:57 PM1.toByte().equals(1)
,
not fine (though suggested): 1.toByte() == 1
Viktor Qvarfordt
05/16/2019, 8:48 PMmyList.map(muFun)
? I know there is myList.map { myFun(it) }
but it requires me to explicitly call the function, if we compare to other languages this is often an anti-pattern.reik.schatz
05/17/2019, 9:57 AM*
?rishabhsinghbisht
05/17/2019, 12:08 PMYossi Saiada
05/17/2019, 12:27 PMFudge
05/17/2019, 7:16 PMxenoterracide
05/17/2019, 7:53 PMRandom
only java.util.Random
, trying to call Random.nextDouble
, I have implementation(kotlin("stdlib-jdk8"))
Dico
05/18/2019, 3:24 AMjooadam
05/18/2019, 4:23 PMRobert
05/18/2019, 7:13 PMvar myInt : Int = ^1L // implicit call toInt() on this Long
or whatever symbol or syntax. Much better than using all sorts of toLong, toInt, toString, toByte etc explicit in code. Losing a lot of the benefits of type inference (if that's the right name)