Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- animals = ["dog", "cat", "chicken", "shark"]
- if 2 + 2 == 5 #obviously this condition will never be true
- # at this point, animal is still undefined
- animal = "frog"
- puts animal
- else
- # animal is now defined as nil, rather than
- # being undefined or defined as "frog"
- puts(animals.find { |animal| animal.length == 5})
- # Rubocop will cite me here for shadowing, becuase it considers animal to
- # still be defined.
- end
- # to see only the relevant offense, run the line below in a terminal:
- # rubocop Test.rb --only Lint
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement