Did you know you can just whip out curly-braces all over the place in Rust and Go?

But why on Earth would you even want to do this?

  • @winnie@lemmy.mlOP
    link
    fedilink
    2
    edit-2
    1 year ago

    I was also confused with explicit return in Kotlin, which behaves differently for inline and non inline functions.

    • Ephera
      link
      fedilink
      21 year ago

      Yeah, in inline functions, you have to use implicit returns, whereas in regular/named functions, you have to use explicit returns.

      Although, there is yet another special case to that rule in that you can use labeled explicit returns in inline functions like so:

      list.map { value ->
          return@map value*2
      }