ilya.gorbunov
05/30/2017, 4:05 PMaerb
05/30/2017, 4:08 PMlateinit var
?pcarrier
05/30/2017, 4:17 PMvoddan
06/16/2017, 11:21 AMarr["a", "b", "c"]
(can be implemented via get
http://kotlinlang.org/docs/reference/operator-overloading.html#indexed)voddan
06/16/2017, 11:24 AMmap {1 + "1"}
(this can be done without generating intermediate objects like pairs)miha-x64
06/16/2017, 11:25 AMmap {
+ "k" to "v"
}
miha-x64
06/16/2017, 11:31 AMsmcvb
06/16/2017, 2:16 PMabstract class AbstractExample(
open val paramOne: Int,
open val paramTwo: String
)
And, the following implementation of the example abstract class:
data class ExampleImpl(
override val paramOne: Int,
override val paramTwo: String,
val paramThree: Boolean
) : AbstractExample(paramOne, paramTwo)
I have to override paramOne
and paramTwo
, because of the following message I get: 'Data class primary constructor must have only property (val / var) parameters'
I'd ideally however have an ExampeImpl
like so:
data class ExampleImpl(
paramOne: Int,
paramTwo: String,
val paramThree: Boolean
) : AbstractExample(paramOne, paramTwo)
Or this at least looks cleaner to me, since this doesn't mean I need to instantiate paramOne
and paramTwo
for ExampleImpl
again and thus use the variables and getter/setter from the AbstractExample
as I'd prefer to.
As far as I know this currently isn't a possibility, hence I dropped in this channel.groostav
06/26/2017, 5:48 PMmap[key]!!
. I suppose this is our mistake and we should instead write map[key] ?: keyNotFound(map, key)
but that's clunkey. Could write an extension function but that means we loose the slick square-brackets syntax, and its though to make idioms without them being part of the standard-lib.bmo
07/11/2017, 8:29 AMprogrammerr47
07/14/2017, 6:04 AMdamian
07/20/2017, 4:59 PMinline val fooFunction: () -> Unit
get() = { println("hello world") }
fun bar() {
fooFunction() // immediate invocation results in complete inlining of "println" body
}
I think this is a pretty obscure use case, but could see it being beneficial for something like funKTionale (using partial application, etc)kirillrakhman
07/21/2017, 1:51 PMvoddan
07/27/2017, 10:12 AMvar list1 = [1, 2] //mutable
let list2 = [3, 4] // immutable list
This is the difference between JVM's reference semantic and Swift's struct/class semantics. It is a fundamental difference in the platforms.benleggiero
07/27/2017, 12:07 PMfoo
(let's say it's 1GB) and then you say var bar = foo
, a "copy" is made, yes. And I'm not 100% sure how, but no delay is incurred. I suspect that you get a new pointer, and any changes you make are reflected as diffs.
Also, let foo = "foo"; let bar = foo
, IIRC, makes foo
and bar
point to the same memory, which is safe because neither can be mutated.dmitry.petrov
07/27/2017, 5:12 PMT
is a reference type (or: is a primitive type)".karelpeeters
07/30/2017, 7:05 PMjoelpedraza
08/02/2017, 5:25 PMkirillrakhman
08/02/2017, 8:43 PMkarelpeeters
08/02/2017, 11:24 PMdmitry.petrov
08/03/2017, 8:38 AMhttps://www.youtube.com/watch?v=xyOLHcEuhHY▾
jlleitschuh
08/04/2017, 6:04 PMbuilder()
method on them that allows data classes created from java to use this builder. Default values that the data classes already have wouldn't be required to be specified in the builder.
What are peoples thoughts on this? I'll open an issue in project KEEP if this is worthy of more feedback.raulraja
08/11/2017, 7:59 PMdean
08/12/2017, 5:29 AMraulraja
08/12/2017, 7:34 PMjimn
08/14/2017, 6:22 AMdmitry.petrov
08/14/2017, 9:01 AMx
in x as T
should be resolved with an expected type T.
So, code like findViewById(...) as MyView
would work as it did before.jw
08/14/2017, 3:10 PMSlackbot
08/15/2017, 6:41 PMgabrielfv
08/15/2017, 8:02 PMfun foo(bar: Int?)
can be called like foo()
, instead of having to write fun foo(bar: Int? = null)
. I see people comonly reading the ?
as sort of "opitional" in this context, and I don't see the point of calling foo(null)
, though makes some sense when
val a: Int? = mayReturnInt()
foo(a)
which is also a common scenariogabrielfv
08/15/2017, 8:02 PMfun foo(bar: Int?)
can be called like foo()
, instead of having to write fun foo(bar: Int? = null)
. I see people comonly reading the ?
as sort of "opitional" in this context, and I don't see the point of calling foo(null)
, though makes some sense when
val a: Int? = mayReturnInt()
foo(a)
which is also a common scenarioumar
08/15/2017, 9:36 PMgabrielfv
08/15/2017, 9:40 PM?
operator they could be null
by default, and there'd be no other possibility for a default value, unlike 0 for Int
or ""
for String
.?
makes it very clear that a value can be null. That's it's role after all.fun foo(a: Int? = 0)
can accept foo(null)
, with a
actually being null
and foo()
with a
being 0
.fun foo(bar: Int)
would not be passive of being called foo()
and would break is not a different behavior, but could be due to the fact that bar
could not be null and therefore there is no way to infer anything.benleggiero
08/16/2017, 1:53 AM?
means "optional parameter", not "nullable and optional". I can imagine newcomers thinking that Kotlin only allows omitted optional parameters to be null and not bothering to discover the =
syntaxgabrielfv
08/16/2017, 4:50 AMfoo(null)
explicitly? Is there any example?umar
08/16/2017, 6:07 AMnull
?