Why doesn’t “case” with “when > 2” work?

It’s not valid ruby syntax.

What you need is

case
  when ARGV.length == 0
    abort "Error 1"
  when ARGV.length > 2
    abort "Error 2"
end

When you write case x, the important part you need to understand is that ruby takes the x and then applies a comparison to the argument or expressions you insert in the when clause.

The line where you say when x >2 reads to ruby like:

if ARGV.length == > 2

When you remove a specific object from the case statements, you can apply conditionals within the when statements .

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)