This page is no longer maintained — Please continue to the home page at www.scala-lang.org

accessing a java instance variable called 'type'

1 reply
Peter Maas
Joined: 2010-03-23,
User offline. Last seen 42 years 45 weeks ago.

Hi all,

since type is a reserved keyword in Scala I can see why I'm not able to read the value of an instance variable of java object called 'type' ... is there a workaround for this; I have no control over the Java code,

Thanks in advance!

Peter

Ruediger Keller 2
Joined: 2010-04-30,
User offline. Last seen 42 years 45 weeks ago.
Re: accessing a java instance variable called 'type'

Put it in backticks and it will be fine:

val mytype = myObject.`type`

Regards,
Rüdiger

2011/6/27 Peter Maas :
> Hi all,
>
> since type is a reserved keyword in Scala I can see why I'm not able to read the value of an instance variable of java object called 'type' ... is there a workaround for this; I have no control over the Java code,
>
> Thanks in advance!
>
> Peter
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland