kirillrakhman
01/25/2017, 2:43 PMilya.gorbunov
01/25/2017, 2:43 PMorElse
, though I'm rather skeptical about whether we should add a function which provides slightly different syntax to the language operator. Please, create a feature request, so we could consider cons and pros there.kevinmost
01/25/2017, 2:46 PMmikehearn
01/25/2017, 4:42 PMto
, sigh), but the reason people object to threading things on Object is partly because the API isn't very good and partly because it imposes runtime costs that are hard to optimise away (though hotspot does a pretty great job of it)mk
01/25/2017, 4:44 PMmikehearn
01/25/2017, 4:45 PMAny
extensions are free at runtime. So that leaves the "not good api" part. Well, other than perhaps being a bit superfluous, functions like let, apply, also etc are too simple to be called APIs. so i think it is not a big deal.mikehearn
01/25/2017, 4:45 PMmikehearn
01/25/2017, 4:45 PMmk
01/25/2017, 4:46 PMrun
on Future
, but realized that this extension would shadow a stdlib method, which I considered a no-go. Adding more methods that are available on Any out of the box takes away room for apps and libraries to extend library types. Maybe it's not a big deal after all, but it is something I noticed.arthur
01/25/2017, 4:46 PMonEach()
? What does this give a developer that you can’t get from forEach()
?
I don’t think it is clear to a new developer to the language that calling onEach()
returns the iterable instance for the next statement in the chain. In the example above I would just call forEach()
in the following way:
.forEach { f ->
println(“Moving $f to $outputDir”)
moveFile(f, File(outputDir, f.toRelativeString(inputDir)))
}
mk
01/25/2017, 4:47 PMfunctions like let, apply, also etc are too simple to be called APIs. so i think it is not a big deal.Maybe not. I guess my general stance is, if they're so simple, people should define them themselves, especially when they can be derived from existing methods
mk
01/25/2017, 4:49 PMarthur
01/25/2017, 4:50 PMmk
01/25/2017, 4:50 PMkevinmost
01/25/2017, 5:01 PMAny
. I know that if they weren't in Standard.kt
, I'd be defining let
, apply
, and also
at the very least in all of my Kotlin projects. That's what a stdlib is for, arguablykevinmost
01/25/2017, 5:10 PMarthur
01/25/2017, 5:12 PMarthur
01/25/2017, 5:12 PMarthur
01/25/2017, 5:14 PMifNullBlock()
iskevinmost
01/25/2017, 5:14 PMmk
01/25/2017, 5:14 PMkevinmost
01/25/2017, 5:14 PMthis
is nullkevinmost
01/25/2017, 5:14 PMkevinmost
01/25/2017, 5:15 PMarthur
01/25/2017, 5:15 PMmk
01/25/2017, 5:16 PMmk
01/25/2017, 5:16 PMT?
will include T
kevinmost
01/25/2017, 5:17 PMNothing
, which is a subtype of T
, but you could also do .orElse { defaultUser }
, for examplemk
01/25/2017, 5:17 PMkevinmost
01/25/2017, 5:17 PM