jurajsolarml
12/17/2018, 1:29 PMursus
12/17/2018, 4:12 PMinterface FooProvider {
fun <T> getFoo() : T <--- works
val <T> foo: T <--- doesnt
}
Ryan Benasutti
12/18/2018, 3:07 AMShawn
12/18/2018, 4:18 PMmasterplanRepository.save()
returns (maybe an instance of the saved record), but if it’s just Unit
, I might suggest writing .apply(masterplanRepository::save)
insteadhho
12/19/2018, 12:51 PMS
is the type of the accumulator (and therefore also the return type).ursus
12/20/2018, 4:52 AMursus
12/21/2018, 3:41 AMdamian
12/21/2018, 11:23 AMval indexes = sensorType.filter { sensorType -> sensorType == 6 }
... how do I instead get an array of the matched indexed positions?poohbar
12/21/2018, 3:46 PMvoid
?
public interface RequestHandler<I, O> {
public O handleRequest(I input, Context context);
}
poohbar
12/21/2018, 3:47 PMO
a Nothing
but that wouldn't compile.. I also tried java.lang.Void
to no avail.Smorg
12/24/2018, 4:49 AMMiguel
12/24/2018, 4:14 PMSmorg
12/24/2018, 10:15 PMKevin
12/25/2018, 5:43 AMKevin
12/25/2018, 10:12 AMKevin
12/25/2018, 10:12 AMKevin
12/25/2018, 11:12 AMwhen(x)
< 1 -> ...
in 2..5 -> ...
6 -> ...
else -> ... (greater than 6)
Kevin
12/26/2018, 1:51 AMjohnfn
12/26/2018, 6:30 PMSam
12/26/2018, 10:41 PMclass Container<T> {
fun useContainedClassType() {
T::class.java
}
}
Ameho Chan
12/27/2018, 2:46 AMShahzad Aslam
12/27/2018, 3:21 PMJoshK
12/28/2018, 10:57 PMfun <E> firstOrderFnWithSecondOrderTypeInference() = { value: E -> value }
, attempting to firstOrderFnWithSecondOrderTypeInference()(42)
gives me a type inference error:
Type inference failed: Not enough information to infer parameter E in fun <E> firstOrderFnWithSecondOrderTypeInference( ) : (E) → E Please specify it explicitly.
firstOrderFnWithSecondOrderTypeInference<Int>()(1234)
works because there's no type inference for E
of the second rank function. I guess what I'm looking for is a why it's like this so I can understand the language a bit better. I know that C++ is the same way, same with Typescript, so I wonder if there's an underlying reason.Shawn
12/29/2018, 7:28 AMpackage
directives and class names rather than filenamesdave08
12/30/2018, 3:12 PMjohnfn
12/30/2018, 7:45 PMSlackbot
01/02/2019, 10:37 AMpoohbar
01/02/2019, 1:47 PMUser
data class which has a type
field. The type can be either REGULAR
or ADMIN
. When it is of type ADMIN
the user will always have a not null companyId
but when it is a REGULAR
user the companyId
will always be null. Therefore the companyId
now has to be nullable and I am forced to handle it even in this case:
val user = db.getUser(id)
if (user.type == ADMIN) {
// user.companyId is definitely NOT NULL here but the compiler obviously has no idea
} else {
// user is a REGULAR user so the companyId is null
The only way around this is to have two different classes: an AdminUser
and RegularUser
that will reflect the reality more closely. Is there a better way?
In Java the compiler does not care and I get no warnings.lsk
01/02/2019, 10:03 PMif ( a == null ) {
do something
} else {
do something else
}
hates
01/03/2019, 10:12 AMhates
01/03/2019, 10:12 AMEgor Trutenko
01/03/2019, 10:20 AMPlacing multiple declarations (classes, top-level functions or properties) in the same Kotlin source file is encouraged as long as these declarations are closely related to each other semantically and the file size remains reasonable (not exceeding a few hundred lines).You can read the whole conventions here: https://kotlinlang.org/docs/reference/coding-conventions.html
hates
01/03/2019, 10:23 AM