articles/ruby-local-variables #28
Replies: 1 comment 6 replies
-
I found your post while investigating how to dynamically define local variables. I figured out a way, so just sharing for the benefit of all of us on the internet:
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
articles/ruby-local-variables
Let’s say you wish to conditionally define a local variable in Ruby. Why would you need that? That’s beside the point, it’s mostly a thought excercise that’s an excuse to learn about a specific corner of Ruby. But, if you still want a real use case, you’re being a bit difficult, but let’s say that you’ve got some metaprogramming code that at some points uses defined?(x) calls to do something based on whether a local variable is defined or not. Yes, it’s very contrived.
https://radanskoric.com/articles/ruby-local-variables
Beta Was this translation helpful? Give feedback.
All reactions