Answers for "ruby check if variable exist and return it"

1

ruby check if exists

apple = 1

defined?(apple)
# "local-variable"

defined?(bacon)
# nil
Posted by: Guest on June-01-2020
0

ruby check if constant exists

Object.const_defined?(const.to_s)
Posted by: Guest on December-16-2020

Code answers related to "ruby check if variable exist and return it"

Browse Popular Code Answers by Language