coffeescript refactoring

coffeescript

Solution

Yes, a `switch` expression:

index = switch segment
  when 'index' then 0
  when 'inbox' then 2
  else 1

Problem

Is there any coffeescript specific trickery that would make this look neater: ``` index = (-> if segment == 'index' return 0 else if segment == 'inbox' return 2 1 )() ```

Original source