ilya.gorbunov
06/02/2016, 7:03 PMfrom(lazySource: Lazy<Any>)
that would wrap lazy into callable.bamboo
06/02/2016, 7:10 PMevanchooly
06/02/2016, 7:11 PMbamboo
06/02/2016, 7:11 PMevanchooly
06/02/2016, 7:12 PMbamboo
06/02/2016, 7:12 PMbamboo
06/02/2016, 7:13 PMbamboo
06/02/2016, 7:16 PMT.() -> Unit
where the original functions are declared to accept Action<T>
bamboo
06/02/2016, 7:19 PMbamboo
06/02/2016, 7:20 PMlazy
) to implement it, how does that sound?ilya.gorbunov
06/02/2016, 7:24 PMbamboo
06/02/2016, 7:24 PMkittinunf
06/03/2016, 7:50 AMholgerbrandl
06/07/2016, 11:32 AMprintln("test" + 1)
println( 1 + " test")
The second line is invalid code because String defines an generic plus kotlin.String.plus
whereas Integer does not do so. This feels odd, especially since Java does both.sreich
06/07/2016, 11:45 AMsreich
06/07/2016, 11:48 AMsreich
06/07/2016, 11:49 AMcy
06/07/2016, 11:52 AMloganj
06/07/2016, 12:28 PMloganj
06/07/2016, 12:30 PMoperator fun Int.plus(str: String): String = toString() + str
loganj
06/07/2016, 12:31 PMudalov
operator fun Any?.plus(String): String
at some point but it was deleted for several reasons, one of them was I believe that it clashed with +
for lists: listOf(“a”) + “b”
should return list of “a” and “b”, not a string [a]b
cy
06/07/2016, 1:50 PMnull + ...
holgerbrandl
06/07/2016, 2:08 PMoperator fun Int.plus(str: String): String = toString() + str
not part of the stdlib? It seems rather common to me. I see why you don't like extensions on Any?
holgerbrandl
06/07/2016, 2:09 PMilya.gorbunov
06/07/2016, 2:09 PMAny?.plus(String)
operator:
- we prefer to have as few extensions for Any?
type or unconstrained generic T
as possible.
- plus
operation tries its best to preserve the form of the first operand, so that List + T
is List
, String + Any?
is String
, Sequence + List
is Sequence
, etccy
06/07/2016, 2:14 PMfun Number.plus(str: String) = toString() + str
?ilya.gorbunov
06/07/2016, 2:15 PMplus
is still valid.cy
06/07/2016, 2:20 PMplus
and plusAssign
looks consistent so that
val s = a + b
var s = a
s += b
cy
06/07/2016, 2:20 PM