pavi2410
08/24/2019, 4:46 PMwords is CharSequence
returns false
. Isn't it wierd?serebit
08/24/2019, 4:54 PMwords
is a List of Strings, not a Stringpavi2410
08/24/2019, 4:57 PMwords
is not CharSequence
, but the method signature says the receiver is CharSequence
which creates the confusion.pavi2410
08/24/2019, 4:58 PMval ls = "abc".split("")
println(ls is CharSequence)
prints false
pavi2410
08/24/2019, 4:59 PMfun main() {
val c = CLASS()
println(c is INTERFACE)
}
interface INTERFACE
class CLASS : INTERFACE
prints true
Kroppeb
08/24/2019, 5:13 PMKroppeb
08/24/2019, 5:14 PMShawn
08/24/2019, 5:26 PMpavi2410
08/24/2019, 5:30 PMKroppeb
08/24/2019, 5:35 PMpavi2410
08/24/2019, 5:39 PMAdam Powell
08/24/2019, 5:42 PMwords
, which is the result of an operation performed on the stringpavi2410
08/24/2019, 5:44 PMwords
is the variable on which chunked
method is called, which is supposed to be of type CharSequence
. I am really confused.Adam Powell
08/24/2019, 5:46 PMIterable<E>.chunked
, as posted in the pic abovepavi2410
08/24/2019, 5:47 PMchunked
function on CharSequence
receiver but Iterable
Adam Powell
08/24/2019, 5:48 PMAdam Powell
08/24/2019, 5:49 PMwords
is not a CharSequence
, so it returns false for the is
checkAdam Powell
08/24/2019, 5:49 PMwords
has the type of `.split(' ')`'s return typeAdam Powell
08/24/2019, 5:50 PMCharSequence
pavi2410
08/24/2019, 5:51 PMfun CharSequence.chunked(size: Int): List<String>
is not the signature of the chunked
call in the example but fun Iterable<T>.chunked(size: Int): List<List<T>>
isAdam Powell
08/24/2019, 5:52 PMpavi2410
08/24/2019, 5:53 PMAdam Powell
08/24/2019, 5:53 PMAdam Powell
08/24/2019, 5:53 PMpavi2410
08/24/2019, 5:54 PMAdam Powell
08/24/2019, 5:54 PMpavi2410
08/24/2019, 5:57 PMKroppeb
08/24/2019, 6:00 PMpavi2410
08/24/2019, 6:01 PMlouiscad
08/25/2019, 12:24 AM