Ruby: Is there a proper way to deny an expression about cases?

A number of blogs and tutorials have different indentation when they implement the case statement. Each of them has a different indentation with respect to the β€œwhen” lines. Is there any best practice for indenting when using a case loop?

+6
source share
2 answers

The consensus is when indentation is at the same level as case .

 case sym when :foo then ... when :bar then ... else ... end 

I think this is well known, and have not seen any reliable sources that state otherwise.

+10
source

So I used it. "What happens when" when "should be on the next line and indented.

 case something when 'a' what happens when 'a' when 'b' what happens when 'b' when 'c' what happens when 'c' end 
+2
source

Source: https://habr.com/ru/post/949671/


All Articles