Ad
  • Default User Avatar

    Privacy. It is not relevant to this example, but it would be a good choice if the programmer did not want the sub-function to be scoped outside of the current function.

  • Custom User Avatar

    Is there a good reason to create the sub-function:

    val getJustIntOrRegister = {key: String -> 
            key.toIntOrNull() ?: registers.getOrDefault(key, 0)
        }
    

    rather than:

    fun getJustIntOrRegister(key: String) = key.toIntOrNull() ?: registers.getOrDefault(key, 0)