< Ruby Programming < Object
i0 = 1
loop {
i1 = 2
print defined?(i0), "\n" # true; "i0" was initialized in the ascendant block
print defined?(i1), "\n" # true; "i1" was initialized in this block
break
}
print defined?(i0), "\n" # true; "i0 was initialized in this block
print defined?(i1), "\n" # false; "i1" was initialized in the loop
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.