Forums
public, static & friends
26 posts
• Page 2 of 3 • 1, 2, 3
Re: public, static & friends
Can you reply again and use the "Upload attachment" to give us your source?
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: public, static & friends
It seems the property must be shared as well.
Try sharing both definitions.
(Chuck, I'll upload the source when I find the right button.)
Try sharing both definitions.
(Chuck, I'll upload the source when I find the right button.)
Last edited by RichS on Sat Feb 09, 2008 12:36 pm, edited 1 time in total.
- RichS
- Posts: 8
Re: public, static & friends
Here it goes (it's a .txt file, because .cobra is not allowed)
- neuruss
- Posts: 23
Re: public, static & friends
RichS wrote:It seems the property must be shared as well.
Try sharing both definitions.
(Chuck, I'll upload the source when I find the right button.)
I tried placing "var _lista = Lista<of Dude>()" and "pro lista from var" in the shared block, but I got this error:
hello2.cobra(35): error: Static member "Dude.Lista.get" cannot be accessed with
an instance reference; qualify it with a type name instead
hello2.cobra(5): warning: (Location of symbol related to previous error)
Compilation failed - 1 error, 1 warning
Not running due to errors above.
- neuruss
- Posts: 23
Re: public, static & friends
Please just forget it!
It was a line of code that I forgot to delete...
Sorry guys!
It was a line of code that I forgot to delete...
print x.lista
Sorry guys!
- neuruss
- Posts: 23
Re: public, static & friends
I believed the attachment didn't work...here it goes again.
- neuruss
- Posts: 23
Re: public, static & friends
I'll have to investigate attachments at some point. I'll be of the forums for awhile now to work on Cobra.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: public, static & friends
Sorry guys, but this is still not clear to me...
I read in another thread that the "public" keyword is recognized in Cobra 0.7.2.
Indeed, this compiled:
However, this member doesn't behave as public...
So I'm back to my original question:
Is it possible to declare a member as public (without having to create a property from it?)
neuruss
I read in another thread that the "public" keyword is recognized in Cobra 0.7.2.
Indeed, this compiled:
var _name as String is public
However, this member doesn't behave as public...
So I'm back to my original question:
Is it possible to declare a member as public (without having to create a property from it?)
neuruss
- neuruss
- Posts: 23
Re: public, static & friends
In the following code, _classVariable is freely accessible to anyone (including Bob) by using Bob._classVariable, and the value will be the same for everyone.
_instanceVariable is freely accessible to anyone who has an instance of Bob, but the value will depend on the particular instance.
_instanceVariable is freely accessible to anyone who has an instance of Bob, but the value will depend on the particular instance.
class Bob
shared
var _classVariable as String is public
var _instanceVariable as String? is public
class Program
def main is shared
Bob._classVariable = "Yo"
a = Bob()
a._instanceVariable = "baby"
b = Bob()
b._instanceVariable = "and then some more"
print Bob._classVariable
print a._instanceVariable
print b._instanceVariable
- khjklujn
- Posts: 29
26 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 39 guests