Advertisement
Guest User

Untitled

a guest
May 11th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.21 KB | None | 0 0
  1. class My
  2.   def value
  3.     "hello world"
  4.   end
  5. end
  6.  
  7. m = My.new
  8. some_value = 21
  9. m.send(:define_method, :value) { some_value }
  10. m.value # => 21
  11. some_value = 42
  12. m.value # => 42 but I would like it to still be 21
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement