--20cf30334973a2fc0604b73079ef
Content-Type: text/plain; charset=UTF-8

On Mon, Jan 23, 2012 at 11:40 AM, Robert Klemme
<shortcutter / googlemail.com>wrote:

> On Mon, Jan 23, 2012 at 11:35 AM, Peter Vandenabeele
> <peter / vandenabeele.com> wrote:
> > On Mon, Jan 23, 2012 at 11:33 AM, Peter Vandenabeele <
> peter / vandenabeele.com
>
> >> Feature request:
> >>
> >> Based on this discussion, it would actually be useful to me if I could
> >> shorten this:
> >>
> >>   amount  igDecimal.new("15.5")
> >>
> >> to
> >>
> >>   amount  5.5B
>
> Bad idea IMHO because this requires a parser change and also makes all
> programs implicitly require "bigdecimal" which is usually not needed.
>
> > Maybe
> >
> > 15.5D
> >
> > is better naming (maps to "Decimal" and the %d of format string).
>
> Or
>
> amount  5.4.to_bd
>

Thanks for the idea.

I fixed my feature request with this code in
a library file:

  require 'bigdecimal'
  class ::String
    def to_bd
      BigDecimal.new(self)
    end
  end

So it only works on strings (that's what I want).

Now I can say:

describe "balance setter and getter" do
      subject.balance  15.4".to_bd
      subject.balance.should "15.4".to_bd
end

Thanks again,

Peter

--20cf30334973a2fc0604b73079ef--