jw
03/06/2018, 11:49 PMjw
03/06/2018, 11:51 PMelect
03/07/2018, 10:29 AMasad.awadia
03/07/2018, 2:10 PMclass ListNode(var v: Int = 0) {
var next: ListNode? = null
}
let's say we have this definition for a listNode [linkedList node] and then we do something like this to fill the listasad.awadia
03/07/2018, 2:10 PMvar headNode: ListNode? = null
(1..10).forEach {
// fill list 1 -> 2 -> 3 -> 4...-> 10
}
// we have lost 'pointer' to head node
asad.awadia
03/07/2018, 2:10 PMasad.awadia
03/07/2018, 2:11 PMheadNode = headNode.next
marstran
03/07/2018, 2:13 PMmarstran
03/07/2018, 2:13 PMjw
03/08/2018, 11:18 PMdiesieben07
03/08/2018, 11:19 PMholgerbrandl
03/15/2018, 1:24 PMbooleanArrayOf(true, false, false).any()
returning false? In other languages it is usually a condense method, to detect the presence of at least one true
. Like in https://stat.ethz.ch/R-manual/R-devel/library/base/html/any.html or https://docs.scipy.org/doc/numpy/reference/generated/numpy.any.html. I know it’s because any does not work in a boolean way, but just indicating a non-empty list. Still it’s confusing.jkbbwr
03/15/2018, 1:26 PMfun main(args: Array<String>) {
println(booleanArrayOf(true, false, false).any())
}
outputs true
holgerbrandl
03/15/2018, 1:26 PMbooleanArrayOf(false, false, false).any()
. Since none of them is true
, I’d expect an any
impl to return false
.elizarov
03/15/2018, 1:28 PMany { it }
is what you are looking for, but a plain any()
on a boolean array is indeed confusing. Maybe it should be deprecated with a warning…..holgerbrandl
03/15/2018, 1:34 PMany()
needed at all, given that there’s the semantically less confusing isNotEmpty()
?diesieben07
03/15/2018, 1:39 PMisNotEmpty
is only declared for Collection
, since it does not try to iterate the collection. any
works for Iterable
and Sequence
, too, by trying to iterate it.holgerbrandl
03/15/2018, 1:54 PMany
works for all collection types, and will give the same result as isNotEmpty
for Collection
? If so, doesn’t this make this isNotEmpty
obsolete/redundant?diesieben07
03/15/2018, 1:56 PMif (collection.isNotEmpty())
imho.holgerbrandl
03/15/2018, 1:59 PMany
to isNotEmpty
across all collection apis and getting rid of the duplicate method? As a nice side-effect this would also remove the confusion about boolean arrays.diesieben07
03/15/2018, 1:59 PMany
.groostav
03/19/2018, 10:14 PMlouiscad
03/21/2018, 1:01 PMSortedSet
and TreeSet
type aliases marked as internal in Kotlin 1.2.30 stdlib ?
// also @SinceKotlin("1.1")
internal typealias SortedSet<E> = java.util.SortedSet<E>
internal typealias TreeSet<E> = java.util.TreeSet<E>
Also, the commented line is weird.karelpeeters
03/21/2018, 1:11 PMlouiscad
03/21/2018, 1:23 PMholgerbrandl
04/04/2018, 9:21 AMkarelpeeters
04/04/2018, 2:27 PMkarelpeeters
04/04/2018, 2:53 PMkarelpeeters
04/04/2018, 2:54 PMkarelpeeters
04/04/2018, 2:54 PMimages(2).png▾