alchzh
11/20/2017, 2:26 PMdalexander
11/20/2017, 3:26 PMbag.kt -> Bag.kt) In Bag#equals return num == (other as Bag).num; will cause a ClassCastException if other is ever not a Bag, so that should use a type check other is Bag prior to attempting to cast. JUnit tests are typically in their own directory, but since this looks like it’s not its own project that might not be manageable.dalexander
11/20/2017, 3:28 PMAndreas Sinz
11/20/2017, 4:09 PMmap, filter and use them instead of all those forEach and local mutable statealchzh
11/20/2017, 9:15 PMmap and filter compare performance wise to for loops and forEach?Andreas Sinz
11/20/2017, 10:07 PMforEach is similar to map etc., they are all inlined functions. The biggest difference between for loops and higher order functions like map is, that the latter creates two additional objects. Both get compiled into a simple while-loop (https://blog.gouline.net/kotlin-bits-for-loops-vs-foreach-30548d7472a5) So the performance is be similar