Created
April 20, 2021 14:10
-
-
Save lukassup/ffb3cd719707f9a8348280312c9bc5d4 to your computer and use it in GitHub Desktop.
Shooting oneself in the foot using Ruby, pt1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
current = 'Silver' | |
if current = 'Gold' | |
# ^ oh no, a mistake! should've been == | |
puts 'Yay! Found gold' | |
else | |
puts "#{current} is not gold" | |
end | |
# This is valid Ruby code and the error is very easy to miss unless you run the code and see the warning: | |
# $ ruby demo.rb | |
# demo.rb:7: warning: found `= literal' in conditional, should be == | |
# Yay! Found gold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment