cy
09/13/2016, 6:37 PMval handled = collisionChecker.getClosetAround(this)?.let { collided ->
// a lot of stuff happens here, not just simple chained calls
}
kevinmost
09/13/2016, 6:37 PM.getClosestAround(this)
returns an Optional<T>
kennycason
09/13/2016, 6:37 PMfun getClosetAround(entity: Entity): Collided?
kevinmost
09/13/2016, 6:38 PMjava.lang.Optional<T>
. Apologieskevinmost
09/13/2016, 6:38 PMOptional
, I didn't realize you meant T?
kennycason
09/13/2016, 6:39 PMkennycason
09/13/2016, 6:39 PMhandled
in this case?kennycason
09/13/2016, 6:39 PMkennycason
09/13/2016, 6:39 PMkennycason
09/13/2016, 6:39 PMkevinmost
09/13/2016, 6:39 PMkennycason
09/13/2016, 6:40 PMif (collided != null) {
// stuff
} else {
// other stuff
}
kennycason
09/13/2016, 6:41 PMkevinmost
09/13/2016, 6:41 PMcollided?.let {
// not null
} ?: run {
// null
}
I guesskevinmost
09/13/2016, 6:41 PMif (collided == null)
kennycason
09/13/2016, 6:42 PMkennycason
09/13/2016, 6:42 PMif (collided?) { stuff } else { other stuff }
a possible syntax to consider?kennycason
09/13/2016, 6:44 PM== null
check looks bettercy
09/13/2016, 6:52 PMcollisionChecker.getClosetAround(this)?.let { collided ->
state.gravityState = GravityState.GROUNDED
setPosition(position.x, collided.rectangle.y + collided.rectangle.height)
velocity.y = 0.0f
state.landTime = System.currentTimeMillis()
}
?: collisionChecker.getOneBelow(this)
?: run { state.gravityState = GravityState.FALLING }
cy
09/13/2016, 6:52 PM?:
looks slightly strange as they are hanging in the voidcy
09/13/2016, 6:53 PMif (collided?)
is not good at allcy
09/13/2016, 6:54 PMcy
09/13/2016, 6:54 PMcollided: Boolean?
cy
09/13/2016, 6:54 PMcollided = false
?cy
09/13/2016, 6:55 PMtokie
09/13/2016, 7:29 PMmethod.isAnnotationPresent(NoDefaultView::class.java)
kennycason
09/13/2016, 7:52 PM.nil?
, but i’m guessing form an explicitness point of view something like isPresent
would be most clearsemoro
09/13/2016, 7:56 PMmethod.annotations.filter { it.annotationClass == NoDefaultView::class }.firstOrNull()
method should be of type KAnnotatedElement
tokie
09/13/2016, 8:27 PMmaxsherry
09/14/2016, 1:26 AM