serebit
11/22/2018, 11:25 PMJakub Aniola
11/23/2018, 11:33 AMkenkousen
11/23/2018, 8:55 PMlistOf(...)
is immutable (er, unmodifiable)? I tried to use reflection to list the functions on the resulting object, but all the add
, remove
, etc, methods are still there.Davio
11/24/2018, 7:15 AMjdiaz
11/24/2018, 6:38 PMNir Golan
11/24/2018, 7:28 PMagrosner
11/25/2018, 2:38 AMHexa
11/25/2018, 12:42 PMif(!item.name.isNullOrEmpty()){
itemMap["name"] = AttributeValue().withS(item.name)
}
Dalinar
11/25/2018, 2:49 PMigor.wojda
11/26/2018, 11:39 AMenum class LastFmImageSize {
@field:Json(name = "medium")
MEDIUM,
@field:Json(name = "small")
SMALL
}
Want
enum class LastFmImageSize {
@field:Json(name = "medium") MEDIUM,
@field:Json(name = "small") SMALL
}
zachtib
11/26/2018, 2:41 PMreik.schatz
11/26/2018, 3:25 PMval start = 0
and listOf(3, 3, 3, 2)
representing sizes of IntRange’s, whats the simplest way to turn this into a list of IntRanges? expected outcome listOf(IntRange(0, 2), IntRange(3, 5), IntRange(6, 8), IntRange(9, 10))
tjsnell
11/26/2018, 5:49 PMSlackbot
11/26/2018, 8:35 PMDaniel
11/27/2018, 4:59 PMlistOf(1, 2, 3) -> (1, 2); (1,3); (2,1); (2,3); (3,1); (3,2)
IAmRasputin
11/27/2018, 6:50 PMInputStream
and loops over it, reading fixed-size chunks of bytes from it. However, it uses the Java idiom where assignment is used as an expression:
byte[] buffer = new byte[CHUNK_SIZE];
while ((bytesRead = stream.read(buffer, 0, CHUNK_SIZE)) != -1) {
// do things
}
Kotlin, of course, does not like this, as assignments are not expressions. Is there an idiomatic way to iterate over sized chunks from a stream, like lines
but less text-oriented? I could call read
inside and outside the loop, but I'd like to avoid that if possible.aaverin
11/28/2018, 9:05 AMlistOf(1,2,3,4,5).forEach {
if (it > 3) //actually evaluates 5 times
return@forEach
}
Any way to stop forEach
without using the label?igor.wojda
11/28/2018, 9:27 AMBernhard
11/28/2018, 10:13 AMdMusicb
11/28/2018, 9:20 PMdata class Testing(val test: Int = 5)
var test: Testing? = null
if (test == null) test = Testing(3)
test.test // works
test = test.copy() // works
for (i in (1..10)) {
test = test.copy() // complains about test being Testing?
}
bdawg.io
11/29/2018, 2:30 AMtyjka
11/29/2018, 2:47 AMfun Any.castTo(cast: Something) = this as cast
What should be in place of Something for this function to work?Shawn
11/29/2018, 2:56 AMinline fun <reified T> Any.castTo() = this as T
but a) that probably won’t work, b) why do you need this as a function?igor.wojda
11/29/2018, 9:50 AMval a = 12
val binaryString = a.toString(radix = 2)
//how to convert binaryString back to Int? Is there any build in function in stdlib?
phldavies
11/29/2018, 12:22 PMbod
11/29/2018, 12:44 PMequals
work for sealed classes?hudsonb
11/29/2018, 1:44 PMreified R
I would like to return a default comparator to use based on `R`s type. Is there any way to do something like this?
inline fun <reified R> defaultComparator(): Comparator<R>? = when {
R::class.isSubclassOf(Comparable::class) -> naturalOrder<R>() // Error: Type arg not within bounds
// ... others
else -> null
}
poohbar
11/29/2018, 2:26 PMlouiscad
11/29/2018, 4:08 PMcarolos
11/29/2018, 4:25 PMcarolos
11/29/2018, 4:25 PMcbruegg
12/01/2018, 4:12 PM