Guest User

Untitled

a guest
Oct 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.17 KB | None | 0 0
  1. #メソッドの内側から自分のスコープの外にある変数を処理出来る
  2.  
  3.  
  4. def hoge x
  5. x + yield
  6. end
  7.  
  8. x = 2
  9.  
  10. p hoge(1){x += 2 } #=> 5
  11. p x #=> 4
Add Comment
Please, Sign In to add comment