0

I have a feature

feature --compare
is_less alias "<" (other: MONEY): BOOLEAN
        -- Is current money less than `other'?
    local
        temp: BOOLEAN
    do
        temp := cents < other.cents
        Result := temp
    end

It just checks two number of cents (cents < other.cents) is greater than. I cannot get the Result to return true even if i set it too true:

Result := temp -----> Result := true

Umer Z
  • 200
  • 10
  • `print (create {MONEY}.make (1) < create {MONEY}.make (2))` prints `True` for me. How do you call feature `is_less` from `MONEY`? – Alexander Kogtenkov Jan 27 '14 at 08:49
  • Say i have two MONEY objects m1 and m2. m1.is_less(m2) – Umer Z Jan 27 '14 at 08:58
  • `create m1.make (1); create m2.make (2); print (m1.is_less (m2))` prints `True` for me as well. Is it different for you? Which compiler version do you use? What is the type of `cents`? – Alexander Kogtenkov Jan 27 '14 at 09:02
  • I get false with that statement. I am using 13.11. cents is INTEGER_64 – Umer Z Jan 27 '14 at 09:12
  • It still works flawless for me with the version of the compiler you mention. I would suggest you to post complete code of the example with the issue to their [support site](http://support.eiffel.com/). – Alexander Kogtenkov Jan 27 '14 at 09:37

1 Answers1

0

I am using 13.11 and it works well for me.

is_less alias "<" (other: like Current): BOOLEAN
    require
        not_void: other /= Void
    do
        Result := cents < other.cents
    end

In another class I call this function and it works as expected.

do_compare
    local
        m1, m2: MONEY
    do
        create m1.make_from_volume (1)
        create m2.make_from_volume (2)
        print(m1.is_less (m2))
    end

So I wonder how did not check if the Result is True or not? How did you pass the argument to it?

Alex.Zhang
  • 123
  • 1
  • 1
  • 6