Skip to content

Comment on The Ruby Style Guideparent

Comments

No, everyone does most assuredly not agree on readability when it comes to case statements. Flat case reads better, and indenting it would be like indenting "elsif" and "else" in an else statement.

yeah, even more, taking the example from the style guide, if lines are short enough, I love doing:

  case
  when song.name == 'Misty' ; puts 'Not again!'
  when song.duration > 120  ; puts 'Too long!'
  when Time.now.hour >  21  ; puts "It's too late"
  else
    song.play
  end
even more, for simple if/elses, many times I do:
  if member.coding_style.vertical_align?
  then friends << member
  else member.show_example(code)
  end
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.