Ruby - Variables
Ruby - Variables
video
class C
puts "in a class: #{$global}" #Result
C.new.my_method
What does x print to the screen in each case? Do they both give errors? Are
the errors different? Why?
© 2022 By Sun* - Talent Incubator Vietnam Unit - All rights reserved 11
5. Exercise
The first prints 3 to the screen.
The second throws an error undefined local variable or method because x is not
available as it is created within the scope of the do/end block.