Skip to content

Instantly share code, notes, and snippets.

@JonathanWThom
Last active June 12, 2021 07:15
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 JonathanWThom/3f44c1daae9d41adf3397cdccf60ed31 to your computer and use it in GitHub Desktop.
Save JonathanWThom/3f44c1daae9d41adf3397cdccf60ed31 to your computer and use it in GitHub Desktop.
Ruby shadowing method example
# https://thomasleecopeland.com/2017/04/20/shadowing-bug-in-the-wild.html
# https://docs.ruby-lang.org/en/2.4.0/syntax/assignment_rdoc.html#label-Local+Variables+and+Methods
# https://www.codinginthecrease.com/news_article/show/307337
class Okay
def yep
"yep"
end
def nope
puts "yep: #{yep}"
if false
yep = "nope"
end
puts "yep: #{yep}"
end
end
Okay.new.nope
# yep: yep
# yep:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment