Forums

enum flags

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

enum flags

Postby kobi7 » Thu Nov 15, 2012 12:25 am

Hi!
I'm not sure what I'm doing wrong.
I can't find the someEnum.hasFlag(flag) method, that is available in .net 4.

is there a ref I need to add?
is System.Core and cobra.core the same?

thanks for the help
kobi
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: enum flags

Postby Charles » Thu Nov 15, 2012 7:25 am

Cobra does not currently pick up on .hasFlag. You can use the bitwise and-operator (&) to test flags, same as in most languages and documented here:

http://cobra-language.com/trac/cobra/wiki/Enum

if someThing & Thing.Foo, print 'test passed'
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: enum flags

Postby kobi7 » Thu Nov 15, 2012 10:21 am

Thanks Charles.
I thought cobra has full interoperability with the .net library.. that was the misunderstanding.
some usings are auto-loaded in C# (System, I think)
so my thinking was that Enum is hiding there, while in cobra I should be explicit with "use" in order to have it.

can you clarify on that regard? thanks!
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: enum flags

Postby kobi7 » Thu Nov 15, 2012 10:27 am

oh, I now read what you pointed to.
so you built flag checking into the language - very nice!
hurray to less cryptic syntax
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel


Return to Discussion

Who is online

Users browsing this forum: No registered users and 98 guests

cron