From: Joel VanderWerf Date: 2013-03-21T06:54:48+09:00 Subject: Re: [ANN] fixedpnt 0.0.1: Binary Fixed Point Calculations On 03/20/2013 07:25 AM, Axel Friedrich wrote: > https://github.com/Axel2/fixedpnt.rb > Allows simulating binary fixed point calculations done in hardware. A random api suggestion... consider using #[]= as an alias for #assign, following this example: >> class A; def []=(v); @x = v; end; def []; @x; end; end => nil >> a = A.new => # >> a[] = 3 => 3 >> a[] => 3 >> a => # You can think of [] as a "dereference operator" for boxed values. As a bonus, ruby gives these operators some basic assignment semantics: >> y = a[] = 4 => 4 >> y => 4 This works regardless of the actual return value of #[]=. And: >> b = A.new => # >> b[] ||= 42 => 42 >> b[] => 42 The line b[] ||= 42 is roughly the same as b[] = b[] || 42 and causes a call to #[] followed by #[]=.