ylemoigne
02/28/2018, 12:08 PMsomeList.map(::Foo)
and someList.map { Foo(it) }
?janvladimirmostert
02/28/2018, 4:19 PMpoohbar
02/28/2018, 4:48 PMagrosner
02/28/2018, 6:29 PMursus
03/01/2018, 4:19 AMribesg
03/01/2018, 7:42 AMhhariri
03/01/2018, 12:21 PMArun
03/01/2018, 2:36 PMbuildString()
?
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/build-string.htmllocke
03/01/2018, 3:57 PMJoakim Fast
03/01/2018, 4:33 PMShawn
03/01/2018, 5:44 PM@kotlin
hasn’t posted that yetbrabo-hi
03/01/2018, 5:49 PMpoohbar
03/01/2018, 6:46 PMfun `hi hello`()
The name of the function now has a suggestion on it: "Remove redundant back ticks". They are not redundant and the action does nothing. Could anyone confirm?tschuchort
03/01/2018, 7:01 PMvlad
03/01/2018, 9:30 PMjtravis
03/01/2018, 11:15 PMwhen
exhaustively when looking through some sealed classes, but there is no real result from each of the when
clauses. The best I can currently do appears to be below:
val someVariableThatDoesntDoAnything = when(some) {
is FirstClass -> {}
is SecondClass -> {}
}
It seems like it would be nice to allow val _ = when(some) { ... }
jermainedilao
03/02/2018, 3:13 AMsindrenm
03/02/2018, 12:50 PMas? String
and as String?
? 😒imple_smile:)Andreas Sinz
03/02/2018, 2:32 PMorangy
03/02/2018, 4:42 PMylemoigne
03/02/2018, 6:33 PMFoo
out of my control which has a method named div(Bar bar)
; Kotlin seems to allow the usage of this method as an operator
. But this method, is not really what you can expect for a division. And I would like to implement the operator fun Foo.div(bar:Bar)=division(bar)
to get the right action.... But as div
exist, the extension is shadowed. I suppose I'm completely out of luck ? (No way to tell kotlin that the div()
method in the class is not an operator method ?)patapon
03/03/2018, 12:02 PMylemoigne
03/03/2018, 5:02 PMPackage name does not match containing directory
vs In pure Kotlin projects, the recommended directory structure is to follow the package structure with the common root package omitted
). And is there a way to give IntelliJ the "base" package for new files under root ?tipsy
03/03/2018, 8:12 PMby lazy
supposed to work when calling from java?ylemoigne
03/03/2018, 8:15 PM/
in it)liz3
03/04/2018, 1:47 AM@FXML
private ListView<String> entriesList;
@FXML
private TextField hostField;
@FXML
private TextField nameField;
@FXML
private PasswordField passField;
@FXML
private TextField pathField;
@FXML
private Button testConnBtn;
@FXML
private Button saveBtn;
@FXML
private Button delBtn;
@FXML
private Button saveNewBtn;
@FXML
private TextField customPath;
@FXML
private ComboBox<String> typeBox;
cedric
03/04/2018, 4:31 AMlateinit
is very useful when your objects are being managed by a container, and containers typically separate object instantiation from object initializations. Some example containers would be Android, the servlet spec, and probably many others. Technically, lateinit
has nothing to do with Java and nothing to do with dependency injection.karelpeeters
03/04/2018, 3:23 PMmore values are of typeBut less values are of typecompared toAny
String
(Any) -> Unit
then of (String) -> Unit
, so the former is more specific.CodeIsmail
03/04/2018, 8:41 PMjcminarro
03/04/2018, 9:18 PMwhen
expresion and I would like to share with you and see what you think about it.
I have created a repo that reproduces the problem that I had, you can check here: https://github.com/JcMinarro/SealedClass
The problem was with some Sealed Class that has some object class
. The IDE, when autocomplete the remaining branches, if some of the cases is an object class
doesn't add the is
operator at the beginning. I though that the operator is
was redundant when it was used inside of when
with an object class
but It is not the same. I had the problem when I serialized/deserialized that object class
and I could see that I got a kotlin.NoWhenBranchMatchedException
jcminarro
03/04/2018, 9:18 PMwhen
expresion and I would like to share with you and see what you think about it.
I have created a repo that reproduces the problem that I had, you can check here: https://github.com/JcMinarro/SealedClass
The problem was with some Sealed Class that has some object class
. The IDE, when autocomplete the remaining branches, if some of the cases is an object class
doesn't add the is
operator at the beginning. I though that the operator is
was redundant when it was used inside of when
with an object class
but It is not the same. I had the problem when I serialized/deserialized that object class
and I could see that I got a kotlin.NoWhenBranchMatchedException
Andreas Sinz
03/04/2018, 9:35 PMis
compares the types, without is
it checks whether its the same runtime-instance. if you serialize/deserialize an object
, it is a new runtime instanceis
when working with a sealed class
jcminarro
03/04/2018, 9:37 PMis
it compare the value. I would like that IDE suggest you to use always is
when you work with a sealed class
Andreas Sinz
03/04/2018, 9:39 PMraulraja
03/04/2018, 10:03 PMMySingleton.type
explicit synthetic type to be able to refer to the types of singleton objects but in Kotlin we have ambiguity:
when (a) {
is B -> // type comparison works for class an object
}
when (a) {
B -> //ambiguos comparison equals based comparison takes precedence
}
Both case would compile fine but in the second one the semantics of the program change since when defaults matches to equals comparison.B
is a class it would be compared by type but if it's an object it would be compared against the object value and not the object type.Andreas Sinz
03/05/2018, 8:40 AMa.equals(B)
where B
is the "only" instance of object B
B
is a class. You either need to use is B ->
to compare the types or B() ->
to compare with equals
raulraja
03/05/2018, 10:36 AMB ->
is valid for classes. If B
was a class it would do a type comparison but if it's an object uses equals based comparison. You can see in @jcminarro repo how the test fails even compiling fine. If you add is B ->
then it performs the right comparison. This is going to be confusing as it stands in Kotlin to many users and has the potnetial to introduce runtime woas and bugs because of ambiguity. Refactoring the class to an object is common and when
cases left behind will still compile but yield a different behavior at runtime.Andreas Sinz
03/05/2018, 11:07 AMclass B
, B ->
does not compile here with the message: Classifier 'B' does not have a companion object, and thus must be initialized here
. In his repo he has SomeSealedClass.SomeObjectClass -> false
which is an object and is SomeSealedClass.SomeDataClass -> true
which is a data class. I can't find any occurence of SomeDataClass ->
without is
in his testsraulraja
03/05/2018, 11:40 AM