untyped variables in classes...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

untyped variables in classes...

Furash Gary
Message
I'd like to be able to do:
 
class X {
  a = null;
  b = null;
 
  x(newA, newB) {
    a = newA;
    b = newB;
  }
}
 
but beanshell doesn't like this - it wants me to type a and b (e.g., list, etc.)  Am I doing something wrong?
 
Gary Furash, Applications Manager, Maricopa County Attorney's Office
 
Reply | Threaded
Open this post in threaded view
|

Re: untyped variables in classes...

patniemeyer
> I'd like to be able to do:
>
> class X {
>   a = null;
>   b = null;
>
>   x(newA, newB) {
>     a = newA;
>     b = newB;
>   }
> }
>
> but beanshell doesn't like this - it wants me to type a and b (e.g.,
> list, etc.)  Am I doing something wrong?

Well, that code compiles ok for me under the latest (if you make the
constructor name match).  I'm assuming that the problem you see is that
the variables a and be are not exposed through the genreated class...
Right now untyped vars do not get generated into the class API.  They are
there and visible internally to the body of the class, but not visible
through the compiled class.  I think this is consistent with the fact that
you could create new undeclared variables in that scope at any time during
the life of the class and we couldn't add them to the compiled class for
you without reloading...

Untyped methods, on the other hand, do get generated with a default return
type of Object and visibility of package.


Pat





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. <a href="http://ads.osdn.com/?ad_idt77&alloc_id492&op=click">http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users