Czar
07/04/2017, 8:41 AM.map { it as SomeSpecificType }
dawidhyzy
07/04/2017, 12:06 PMgroups = arrayOf("g1")
ossama
07/04/2017, 1:08 PMevanchooly
07/04/2017, 1:59 PMjw
07/04/2017, 4:33 PMross_a
07/04/2017, 4:42 PMjw
07/05/2017, 3:58 AMzeugederunity
07/05/2017, 11:09 AMmenegatti
07/05/2017, 12:30 PMpublic fun <T> Foo(T target) where T : Controller, T: OnDoneCheck { }
tarlekon
07/05/2017, 2:26 PMK2JVMCompiler
?aa
07/05/2017, 3:31 PMthinkter
well?kevinmost
07/05/2017, 6:47 PMreturn Unit.INSTANCE;
badlogic
07/05/2017, 10:01 PMbadlogic
07/05/2017, 10:01 PMbloodshura
07/06/2017, 12:41 AMwhen
clause must only be exhaustive when it's a single-expression function or assignment?rockerhieu
07/06/2017, 6:55 AMpublic final class Utils {
public static void somethingUseful() {}
}
I don't see any suggestion to import the static method Utils.somethingUseful()
when writing Kotlin code. Do I need to configure the Kotlin IDEA plugin?evanchooly
07/06/2017, 12:08 PMrajendhiraneasu
07/06/2017, 12:42 PMgroostav
07/07/2017, 2:26 AMrockerhieu
07/07/2017, 8:10 AMopen
only in unit test?semyon.atamas
07/07/2017, 1:05 PMPaul Woitaschek
07/07/2017, 5:19 PMdumptruckman
07/08/2017, 4:03 AMfun CharSequence.getThing(): Thing?
or val CharSequence.thing: Thing?
feels wrong because it makes seem like the Thing belongs to the CharSequence.
fun CharSequence.toThing(): Thing?
feels wrong because it seems like this should throw an exception if the Thing is not found
I'm not really sure what's left. Thoughts?ensirius
07/08/2017, 6:42 AMhttp://i.imgur.com/iwA6PZH.png▾
orangy
07/08/2017, 2:50 PMdevesh525s
07/08/2017, 5:23 PMdumptruckman
07/08/2017, 5:25 PMmplacona
07/09/2017, 10:33 AMgreybird
07/09/2017, 4:22 PMthrows Throwable
implies that a subclass of Throwable may be thrown. So perhaps you don't need the generic type param, from the Java perspective at least. Are you using type E elsewhere in the method?bloodshura
07/10/2017, 2:47 AMgetContent()
, which returns a String? (it is annotated as @Nullable
). However, in the same class, there is another method called isOk()
, which returns a Boolean. If isOk()
returns true
, it means that the String returned by getContent()
will not be null.
Is there any way (like a JSR-305 annotation maybe) I can tell the Kotlin compiler about this?
For now, I'm doing the obvious:
if (response.isOk) {
val content = response.content!!
}
But I don't feel well at all having to use !!
...bloodshura
07/10/2017, 2:47 AMgetContent()
, which returns a String? (it is annotated as @Nullable
). However, in the same class, there is another method called isOk()
, which returns a Boolean. If isOk()
returns true
, it means that the String returned by getContent()
will not be null.
Is there any way (like a JSR-305 annotation maybe) I can tell the Kotlin compiler about this?
For now, I'm doing the obvious:
if (response.isOk) {
val content = response.content!!
}
But I don't feel well at all having to use !!
...agrosner
07/10/2017, 4:14 AMevanchooly
07/10/2017, 7:44 AMresponse.content?.let { ... }
michaelzinn
07/10/2017, 7:45 AMresponse.content?.let { content -> ...
if you want to keep the val’s name.response.isOk and respone.content?.let { content -> {
work?marstran
07/10/2017, 8:14 AMresponse.takeIf { it.isOk }?.content?.let { content -> ... }
if you need to check isOk
. But I think I would use the normal if-test, as most people would find it more readable.Paul Woitaschek
07/10/2017, 8:21 AMif(response.content != null) ... else ...?
response.content?.let {....}
marstran
07/10/2017, 8:23 AMisOk
might check for more than just response.content != null
though.evanchooly
07/10/2017, 8:40 AMisOk
likely is an http response code check. things can be OK
without a response body.karelpeeters
07/10/2017, 8:54 AMdanneu
07/10/2017, 12:36 PM