Hacker News new | past | comments | ask | show | jobs | submit login

That is where you use optional chaining + extension method. And that is basically identical to Optional.map or whatever method in those language with Optional type

in kotlin

  func add3 (val: Int?) = val ?.let { it + 3 }
The language gives you a way to say: `this value plus 3 if it exist or just return null`

Unfortunately, there is no such method in js currently, so it looks half baked.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: