Xóa bài viết
Bạn có chắc chắn muốn xóa bài viết này không ?
Xóa bình luận
Bạn có chắc chắn muốn xóa bình luận này không ?
When are local variables initiated in Ruby
When are local variables initiated in Ruby
In Ruby, everytime we execute 1 function, all local variables in this function will be initialize BEFORE we run code in it.
For example:
# irb
def test_func
binding.pry
if fasle
x = 2
end
end
test_func
If you stay at binding.pry
and call: local_variables
, you can see variable x
is defined, with value = nil, dispite the code x = 2
is not execute.
TuanTran 06-05-2019
Bình luận

{{ comment.user.name }}
Bỏ hay
Hay

Bài viết liên quan

0
5
fCC: Technical Documentation Page note So I have finished the HTML part of this exercise and I want to come here to lament about the lengthy HTML ...

4
0
I used Spring boot, Hibernate few times back then at University, I'v started using it again recently. In this (Link), I want to check how Spring J...

24
1
Toán tử XOR có tính chất: + A XOR A = 0 + 0 XOR A = A Với tính chất này, có thể cài đặt bài toán sau với độ phức tạp O(N) về runtime, và với O(1)...