adam-mcneilly
12/01/2017, 5:21 PMdierre
12/02/2017, 5:55 PMDiaa Jad
12/02/2017, 11:46 PMchar
to an Int
?
var.toInt()
returns the ASCII value of the character.Shawn
12/05/2017, 7:51 PMMap<String, List<String>>
you’re probably going to have to do some castingkatien
12/05/2017, 8:12 PMerrors.mapValues { (_, v) ->
when (v) {
is String -> listOf(v)
is List<*> -> v as List<String>
else -> listOf(v.toString())
}
}
Regan Russell
12/05/2017, 9:33 PMspragg
12/06/2017, 2:45 AMPN10
12/06/2017, 6:47 AMJakub Kornatowski
12/06/2017, 1:26 PMkarelpeeters
12/07/2017, 5:33 PMthingy?.let { Foo(it) } ?: Foo(defaultThingy, additionalParam)
kastork
12/07/2017, 8:53 PMlateinit
vars cannot be primitive types. If you're trying to create a bean-compliant class, how do you designate an Integer
or Double
type? If you make the property type Int
you get the error that primitive types can't be lateinit
, if you give it the type Integer
you get the warning that you shouldn't use Integers
but should use Int
.. And for Double
there doesn't even appear to be a way to say you want the Object Double
and not a primitive double
shamrock_frost
12/08/2017, 12:10 AMclass A
class B : A
class C : A
class X
class Y : X
class Z : X
fun example(a : A, x : X) = when(a, x) {
is B, is Y -> "B and Y"
is C, is Z -> "C and Z"
else -> "Not an interesting case"
}
adam-mcneilly
12/08/2017, 4:55 PMdierre
12/09/2017, 10:21 AMTelegramBots
(https://github.com/rubenlagus/TelegramBots). The goal is to have two running bots, the js and the kotlin one with one common business logic. I hope it's all clear up to this point. Now the question: for testing, on the node js I used jest + nock. Now I would see, as an advantage, the fact that I can use a java/kotlin mock library (I want to mock the telegram API) inside kotlin test. Of course the library that I will use to implement the bot is a javascript library. So, basically, can I implement my telegram bot in kotlin, using telegram bot js library, and testing it with, as an example, OkHttp MockWebServer?techie01
12/11/2017, 11:49 AMdanneu
12/11/2017, 9:51 PMdanneu
12/12/2017, 1:32 AMctx.write(Any)
e.g. ctx.write(response)
in this case. type system can't helpkarelpeeters
12/12/2017, 9:04 AMif(...) then ... else ...
.elye
12/13/2017, 12:58 AMGauthierPLM
12/13/2017, 1:34 PMmelston
12/13/2017, 10:48 PMlawlorslaw
12/14/2017, 6:34 PMdanneu
12/15/2017, 4:45 AMtechie01
12/15/2017, 10:53 AMasad.awadia
12/16/2017, 1:39 AMTachyon
12/17/2017, 1:04 PMvisakha
12/17/2017, 1:44 PMrashadfl
12/17/2017, 7:14 PMdgngulcan
12/17/2017, 9:24 PMKronicDeth
12/18/2017, 3:30 PMprivate set
and custom get
?
java
private ProjctSdksModel myModel
public ProjectSdksModel getModel() {
if (myModel == null) {
myModel = new ProjectSdksModel();
myModel.reset(null);
}
return myModel;
If I try
kotlin
var model: ProjectSdksModel? = null
get() {
if (this.model == null) {
}
return this.model
}
private set
I get warning that this.model
is or model
is recursive and my google-fu is failing for how to refer to the current property inside the getterKronicDeth
12/18/2017, 3:30 PMprivate set
and custom get
?
java
private ProjctSdksModel myModel
public ProjectSdksModel getModel() {
if (myModel == null) {
myModel = new ProjectSdksModel();
myModel.reset(null);
}
return myModel;
If I try
kotlin
var model: ProjectSdksModel? = null
get() {
if (this.model == null) {
}
return this.model
}
private set
I get warning that this.model
is or model
is recursive and my google-fu is failing for how to refer to the current property inside the getterRuckus
12/18/2017, 3:35 PMthis.model
with field
https://kotlinlang.org/docs/reference/properties.html#backing-fieldsKronicDeth
12/18/2017, 3:35 PM!!
immediately after initializing the field
? I assume the mutability warning is for concurrency
get() {
if (field == null) {
field = ProjectSdksModel()
field!!.reset(null)
}
return field
}
Ruckus
12/18/2017, 3:39 PMfield = ProjectSdksModel().apply { reset(null) }
KronicDeth
12/18/2017, 3:41 PMnull
reset back to field
. It's not just a lateinit - there's other code that can reset the field to null
Ruckus
12/18/2017, 3:43 PMreset(null)
does, but a backing property should help separate the logic more cleanly.umar
12/18/2017, 4:32 PM