pepe
08/21/2019, 11:04 AMfun <T: ???, R> T.setDefault(prop: KProperty1<T, R>, defaultValue: R): T =
prop.get(this)?.let { this } ?: copy(??? = defaultValue)
P.S. maybe this I'm trying to do is stupid/not worth it, feel free to point it outribesg
08/21/2019, 12:51 PMstdlib
dependency does what? For example, should I use stdlib-jdk8
for an Android lib/app?javaru
08/21/2019, 3:08 PMStream<T>
to a typed array of Array<T>
?
I need to convert a Map<String,String>
to an Array<Pair<String,String>>
. I've done this as follows:
val array: Array<Pair<String, String>> = myMap.entries.stream().map {
Pair(it.key, it.value)
}.toList().toTypedArray()
Is that the most efficient way? It seems like converting to a List
first and then to the (typed) Array
has an extra step. But I'm not seeing any other way to go from the Stream<Pair<String,String>>
coming out of the map{}
function to a typed Array<Pair<String,String>>
(since Stream.toArray()
would give me an untyped Array of Array<Any>
).changd
08/21/2019, 9:26 PM@Throws
The API
interface StormcrowBase {
@get:Throws(Exception::class)
val featureNames: ArrayList<String>
}
Java call site
try {
features = stormcrowBase.getFeatureNames();
} catch (Exception e) {
e.printStackTrace();
}
The error I'm getting is Exception is never thrown in the corresponding block
.
Any ideas?Leoboyean
08/21/2019, 10:31 PMPaul N
08/22/2019, 8:53 AMval tokenMap = (session.getAttribute(sessionAttributeName) ?: mutableMapOf<String, AgedToken>()) as MutableMap<String, AgedToken>
Which means I do get a compiler warning "Warning:(39, 55) Kotlin: Unchecked cast: Any to MutableMap<String, AgedToken>"
Is there any way I can do this better and get rid of the warning ?Fredrik Larsen
08/22/2019, 10:30 AMSam Garfinkel
08/22/2019, 2:47 PMType?
), but it would be kind of cool to replace those with as?
directly.jmfayard
08/22/2019, 4:13 PMIcaro Temponi
08/22/2019, 4:52 PMgaetan
08/22/2019, 6:11 PMRobert Menke
08/22/2019, 6:13 PMRuckus
08/22/2019, 7:46 PMWorking on an improved Kotlin-to-Java converter.This should say "Java-to-Kotlin". Hopefully someone from JB can fix that.
xenoterracide
08/22/2019, 8:25 PM908D C60A
note: I don’t mean generate a salt I mean literally these bytes, I’m trying to test my algorithm and see if I get the same base64 encoded stringchristiangruber
08/22/2019, 11:40 PMSlackbot
08/23/2019, 6:49 AMAlowaniak
08/23/2019, 7:01 AMwhen(defaultValue::class)
or something like thattateisu
08/23/2019, 7:13 AMarild
08/23/2019, 10:01 AMval
might be const
but it is useful not to make it const
?LastExceed
08/23/2019, 12:11 PMif (x != null) {
y = x
}
is there a shorter way to do this? I recall there being some way by using the ?
operator but im not sure if that was in kotlin or another languagecubesky
08/23/2019, 3:38 PMMarko Mitic
08/23/2019, 4:02 PMinternal
kotlin classes are public
to java code. How to write kotlin library without exposing all classes to java?Saiedmomen
08/23/2019, 6:38 PMKFunction
and KSuspendFunction1
? I have imported imported kotlin-reflect
but I have to manually import them and IDE inspection tools like go to declaration and search in path can't find their declarationLeon K
08/23/2019, 7:35 PMDennis Schröder
08/24/2019, 10:41 AMpavi2410
08/24/2019, 4:46 PMwords is CharSequence
returns false
. Isn't it wierd?pavi2410
08/24/2019, 5:28 PMpavi2410
08/24/2019, 7:19 PMreadLine
function from stdlib which yields each line in the multiline text block. This is supposed to act just like readLine
but reads from a fixed string instead of stdin.
Here is how I'm trying to make it work: https://pl.kotl.in/f-ayPvSC-jmfayard
08/25/2019, 7:58 AMfun String.someExtensionFunction() = "Hello World"
that would be usable only from the right extension block?
dependencies { // this is Dependencies
....
}
That seems impossible because it would require to define the function having two receivers, Dependencies
and String
LastExceed
08/25/2019, 8:04 AMobject
? isn't it basically same as top level members in a separate package?