"Arie Kusuma Atmaja" <[EMAIL PROTECTED]> writes:

> I tested it using Ruby 1.8.6 patch 111 and also Ruby 1.9.0 (revision 15968).
>
> var = nil if false
> var.nil? #=> true
>
> I actually saw it from tobi's blog, then I discussed with a perler who
> loves ruby as well, here's a copy paste. (Bottomline: is it a feature
> or a bug????)

> 12:57:18 PM Rie!: how come it's not a bug :-B var should be undefined local
> var

Feature. Mekanisme yang sama memungkinkan expresi ini:

def foo
 a = a || 2
end

Untuk assignment, the destination variable selalu dibuat dahulu dan
bound ke value ``nil`` jika sebelumnya tidak ada, sebelum mengevaluasi
expresi di sisi kanan. Maka dari itu, reference ke ``a`` di sisi kanan
tidak erroring out.

> 12:57:51 PM edpratomo: try to post that to ruby-talk :-) i believe you
> will get "it's not a bug" replies

It's not a bug.



> 12:56:01 PM Rie!: it's just like the stupid param variable is still
> available outside of the block/yield

Contoh?


YS

Kirim email ke