Where did `Option.applicative()` went with release...
# arrow
s
Where did
Option.applicative()
went with release 1.0? What should I use instead? I'm looking for a way to compose these three
Option
into an object, or
null
otherwise:
Copy code
// example of expected input for string: "10 -55 99"
private fun parseLocation(string: String, dungeonName: String): Location? {
    val args = string.split(' ', limit = 3)
    if (args.size != 3) {
        logger.warning("Invalid location '$string' for dungeon '$dungeonName', skipping this location for now")
        return null
    }
    val x = args[0].toIntOrNull().toOption()
    val y = args[1].toIntOrNull().toOption()
    val z = args[2].toIntOrNull().toOption()
    // use x y and z to create a location
}
s
Hey @SecretX, This was renamed to
zip
to be more in line with Kotlin Std. So you can use:
Copy code
args[0].toIntOrNull().toOption().zip(
  args[1].toIntOrNull().toOption(),
  args[2].toIntOrNull().toOption()
) { x, y, z -> }
You can also use:
Copy code
Nullable.zip(
  args[0].toIntOrNull().toOption(),
  args[1].toIntOrNull().toOption(),
  args[2].toIntOrNull().toOption()
) { x, y, z -> }
s
Thanks, I went with the second option