As a result here are some new ways I learned to get 5 from 2 + 2:
require 'fiddle'
a = 2
b = 2
Fiddle::Pointer.new(a.object_id << 1).to_value.ceil + b
=> 5
Note: This happens because calling `to_value` on the `Fiddle::Pointer` object returns a Float (2.0000000000000004) instead of Fixnum (which was a surprise to me).And here's another using `Object#tap`:
a = 2
(a + a).tap{|x| a = x + 1}.send(:eval,'a')
=> 5
[1] These links were helpful for me. The last one is an MIT licensed book called, "Kestrels, Quirky Birds,
and Hopeless Egocentricity."http://stackoverflow.com/questions/1872110/is-ruby-pass-by-r...
http://patshaughnessy.net/2014/1/9/how-big-is-a-bignum
http://stackoverflow.com/questions/2818602/in-ruby-why-does-...
http://combinators.info/#kestrels
Edit: line formatting