Skip to content

Instantly share code, notes, and snippets.

@lukassup
Created April 20, 2021 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukassup/ffb3cd719707f9a8348280312c9bc5d4 to your computer and use it in GitHub Desktop.
Save lukassup/ffb3cd719707f9a8348280312c9bc5d4 to your computer and use it in GitHub Desktop.
Shooting oneself in the foot using Ruby, pt1
#!/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