0

Consider the following code:

declare
class Test
   attr L
   meth init L:=nil end
   meth put(X) {Browse @L} end
   meth get {Browse @L} end
   meth isEmpty @L==nil end
   meth getList @L end
   meth setNil L:=nil end
   meth union(C) {Browse @L} end
end

When I compile this class it gives error : expression at statement position. I'm checking my little code for about an hour to fix this error but got no luck. Please help me find the problem. Thank you.

Ramin Omrani
  • 3,673
  • 8
  • 34
  • 60

1 Answers1

4

your methods cannot return something! isEmptyand getList should be

meth isEmpty(R) R=(@L==nil) end
meth getList(R) R=@L end

and you can use

T={New Test init}
{Browse {T isEmpty($)}}

to do 'as if it had a return value'

Actually {Browse {T isEmpty($)}} is the same as
local R in {T isEmpty(R)} {Browse R} end

sorry for my bad english

yakoudbz
  • 903
  • 1
  • 6
  • 14