I know you got this code from the docs, but I'll go ahead and explain whats wrong for anyone who might also see this error:
Actor.locals.get(Str,Obj?) returns type Obj?.
So when you use the expression:
1 + Actor.locals.get("count", 0)
The compiler, knowing that 1 is an Int, searches Int for a method named "plus" or "plus<something>", with an @Operator facet, which takes an Obj or Obj? as its only argument.
There is no such method in Int.
You could help the compiler see what you're doing by casting the right hand side to Int:
1 + (Int) Actor.locals.get("count", 0)
brianWed 30 Nov 2011
There is no such method in Int.
Actually the problem is that they are three potential methods plus, plusFloat, and plusDecimal which makes it ambiguous.
That code used to work, but it gotten broken when I fixed ticket 604. This sample code slipped thru the cracks. Thanks for reporting
theGeeko61Wed 30 Nov 2011
Thanks for the quick response... meanwhile, I moved on to the Examples... where the cast is explicitly made...
I returned here to update my post... but you folks are too fast!! LOL
theGeeko61 Wed 30 Nov 2011
I am trying this example from the documentation:
But I am getting a compile-time error on line 4]:
andy Wed 30 Nov 2011
Hey theGeeko61 - Actor.locals is going to return as typed
Obj
so you just need to cast to an Int:Assume you saw this here: /doc/docLang/Actors.html#locals? I will fix.
qualidafial Wed 30 Nov 2011
I know you got this code from the docs, but I'll go ahead and explain whats wrong for anyone who might also see this error:
Actor.locals.get(Str,Obj?)
returns typeObj?
.So when you use the expression:
The compiler, knowing that
1
is anInt
, searchesInt
for a method named "plus" or "plus<something>", with an@Operator
facet, which takes anObj
orObj?
as its only argument.There is no such method in
Int
.You could help the compiler see what you're doing by casting the right hand side to
Int
:brian Wed 30 Nov 2011
Actually the problem is that they are three potential methods
plus
,plusFloat
, andplusDecimal
which makes it ambiguous.That code used to work, but it gotten broken when I fixed ticket 604. This sample code slipped thru the cracks. Thanks for reporting
theGeeko61 Wed 30 Nov 2011
Thanks for the quick response... meanwhile, I moved on to the Examples... where the cast is explicitly made...
I returned here to update my post... but you folks are too fast!! LOL
It's a good thing.