bts.rybicki
11/04/2016, 12:26 PMbts.rybicki
11/04/2016, 12:27 PMbts.rybicki
11/04/2016, 12:27 PMkingsley
11/04/2016, 12:27 PMval itemClickListener: (City) -> Unit = {...}
val cityInfoClickListener: (City) -> Unit = {...}
CitiesAdapter(getCities(), itemClickListener, cityInfoClickListener)
kingsley
11/04/2016, 12:28 PMadapter.itemClickListener = ...
when there are a lot of thembts.rybicki
11/04/2016, 12:29 PMbts.rybicki
11/04/2016, 12:29 PMbamdmux
11/04/2016, 12:29 PMbts.rybicki
11/04/2016, 12:29 PMbts.rybicki
11/04/2016, 12:30 PMdefhlt
11/04/2016, 12:33 PMlistener: ((City) -> Unit)? = null
bamdmux
11/04/2016, 12:33 PMkingsley
11/04/2016, 12:34 PMclass CitiesAdapter(
val cities: List<City>,
val itemClickListener: (City) -> Unit,
val cityInfoClickListener: (City) -> Unit,
...
)
bts.rybicki
11/04/2016, 12:34 PMbts.rybicki
11/04/2016, 12:35 PMadambl4
11/04/2016, 12:35 PMtypealias CityClickListener = (City) -> Unit
bamdmux
11/04/2016, 12:36 PMaddClickListener {whatever()}
instead of using the constructors if that suits you betterbts.rybicki
11/04/2016, 12:38 PMmbstavola
11/04/2016, 5:52 PMfoo.filter {
!bar.contains(it)
}
Basically, all the items in Set A that do not appear in Set B. I was pretty sure there was a functional extension for this, but I can't seem to find it.mbstavola
11/04/2016, 6:11 PMoshai
11/04/2016, 9:33 PMreturn when {
currentCellState == Alive && liveNeighbours < 2 -> Dead
currentCellState == Alive && liveNeighbours >= 2 && liveNeighbours <= 3 -> Alive
currentCellState == Alive && liveNeighbours > 3 -> Dead
currentCellState == Dead && liveNeighbours == 3 -> Alive
else -> Dead
}
oshai
11/04/2016, 9:34 PMwhen Pair(currentCellState, liveNeighbours) { ..
? Any other idea?cedric
11/04/2016, 10:05 PMMap<Pair<State, NeighborCount>, State>
and fill it with (Alive, 0) -> Dead
, (Alive, 1) -> Dead
, etc… up to 8 neighborscedric
11/04/2016, 10:05 PMcedric
11/04/2016, 10:06 PMif
above thoughcedric
11/04/2016, 10:08 PMkqr
11/05/2016, 7:00 AMorangy
orangy
when(currentCellState) {
Alive -> when(liveNeighbours) {
in 2..3 -> Alive
else -> Dead
}
Dead -> when(liveNeighbours) {
3 -> Alive
else -> Dead
}
}
oshai
11/05/2016, 10:53 AM