DEV Community

Discussion on: What's a useful programming language feature or concept that a lot of languages don't have?

Collapse
 
cathodion profile image
Dustin King

Maybe it has something to do with having "one way to do it". I never understood the hate for switch/case statements though. It's a little counter-intuitive how they fall through by default in C/C#/C++, but it's still a common thing to want to map a set of possible values to a set of possible actions.

Or return values! Like in Ruby:

    case serial_code
    when /\AC/
      "Low risk"
    when /\AL/
      "Medium risk"
    when /\AX/
      "High risk"
    else
      "Unknown risk"
    end

There's another thing I like from Ruby and Lisp: you don't have to explicitly return, you can just have the return value be whatever the last expression was.

Collapse
 
tobiassn profile image
Tobias SN

Yeah you’re probably right.