ImXico/Cyberpunk

Improve the usage of type inference in the physics module

ImXico opened this issue · 2 comments

Removing explicit type declarations and letting type inference do the work leads to more idiomatic Kotlin code. A big part of the project already makes use of type inference, but it could be improved inside the physics module (including the files inside the builder folder).

For instance, on PhysicsDebugger.kt, the following:

private val renderer: Box2DDebugRenderer = Box2DDebugRenderer()

Could simply be written as this (notice how the type is infered):

private val renderer = Box2DDebugRenderer()

Another clear case is extension functions, such as the ones defined in PhysicsUtility.kt:

internal fun Float.asPixels(): Float = this * PPM

Could really be just this:

internal fun Float.asPixels() = this * PPM

New changes should be made on a new branch from master.

Hi, I will work on this!

Awesome, good luck! 😄