Next 4.1 More Caveats Prev

More Caveats

Caveat #3. Single code parsing pass. Methods can't be used before definition. There is also some ambiguity, variables vus methods.

error_num = 0
begin
	puts width         if error_num == 0
	width = 12
	puts width

	puts width()       if error_num == 1
	def width
		"30mm"
	end
	puts width()
rescue
	printf "Error %d: %s\n", error_num += 1, $!
	retry
end
Error 1: undefined local variable or method `width' for main:Object
12
Error 2: undefined method `width' for main:Object
12
30mm

Next Ruby for Perl programmers Prev