# Flagged enums

**URL:** <https://www.ruby-forum.com/t/flagged-enums/163833>\
**Category:** IronRuby\
**Created:** [March 25, 2009, 10:42am UTC](https://www.ruby-forum.com/t/flagged-enums/163833 "2009-03-25T10:42:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 25, 2009, 10:42am UTC](https://www.ruby-forum.com/t/flagged-enums/163833/1 "2009-03-25T10:42:24Z")

</div>

Hi,  
it seems that the following code isn’t supported:

AnchorStyles.Bottom | AnchorStyles.Left

I believe IronPython supports this (see EnumOps.cs).

Is that syntax planned ?

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 25, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/flagged-enums/163833/2 "2009-03-25T18:23:02Z")

</div>

IronRuby should support this. Enum values are ints anyway, so that  
behavior shouldn’t be hard to implement.

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Thibaut BarrÃ¨re  
[removed\_email\_address@domain.invalid]  
Sent: Wednesday, March 25, 2009 2:39 AM  
To: ironruby-core  
Subject: [Ironruby-core] Flagged enums

Hi,

it seems that the following code isn’t supported:

AnchorStyles.Bottom | AnchorStyles.Left

I believe IronPython supports this (see EnumOps.cs).

Is that syntax planned ?

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 26, 2009, 5:41pm UTC](https://www.ruby-forum.com/t/flagged-enums/163833/3 "2009-03-26T17:41:04Z")

</div>

> Yes, we can do that.
> 
> thanks for the answer.

I’ll try to create some code to handle that manually until then.

cheers,

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 25, 2009, 6:28pm UTC](https://www.ruby-forum.com/t/flagged-enums/163833/4 "2009-03-25T18:28:57Z")

</div>

Yes, we can do that.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Wednesday, March 25, 2009 2:39 AM  
To: ironruby-core  
Subject: [Ironruby-core] Flagged enums

Hi,

it seems that the following code isn’t supported:

AnchorStyles.Bottom | AnchorStyles.Left

I believe IronPython supports this (see EnumOps.cs).

Is that syntax planned ?

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 29, 2009, 11:53pm UTC](https://www.ruby-forum.com/t/flagged-enums/163833/5 "2009-03-29T23:53:53Z")

</div>

In case it’s useful to someone else (until flagged enums combination is  
supported by IronRuby), I wrote some custom code to support that.  
I’m now allowing code like :anchor =\> [:bottom,:top] in Magic.

## Relevant code is here:

## [Support for flagged enums, ie :anchor =\> [:bottom,:right] · thbar/magic@e236e6f · GitHub](http://github.com/thbar/magic/commit/e236e6fa455ea783b42dd08513dea7d80b4705d5)

> <https://github.com/thbar/magic/blob/e236e6fa455ea783b42dd08513dea7d80b4705d5/lib/magic/enum_support.rb>

cheers,

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [May 26, 2009, 11:46pm UTC](https://www.ruby-forum.com/t/flagged-enums/163833/6 "2009-05-26T23:46:31Z")

</div>

Hi,

a follow-up on flagged enums:

> > AnchorStyles.Bottom | AnchorStyles.Left

I seem to remember a commit that mentioned it was supported, but I’m not  
sure.

Currently, either “||” or “|” fail on this example (| gives method  
undefined, || returns only Bottom).

Has it been implemented ? Should I file a bug for this ? (or is the  
syntax  
different ?)

cheers,

–Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [June 17, 2009, 8:59am UTC](https://www.ruby-forum.com/t/flagged-enums/163833/7 "2009-06-17T08:59:35Z")

</div>

This works now:

> > > AnchorStyles.bottom | AnchorStyles.left  
> > > =\> Bottom, Left

Jim, there should be specs for this. Where should I add them?  
enum/mapping\_spec.rb or somewhere else?

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Tuesday, May 26, 2009 2:38 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Flagged enums

Hi,

a follow-up on flagged enums:

> > AnchorStyles.Bottom | AnchorStyles.Left

I seem to remember a commit that mentioned it was supported, but I’m not  
sure.

Currently, either “||” or “|” fail on this example (| gives method  
undefined, || returns only Bottom).

Has it been implemented ? Should I file a bug for this ? (or is the  
syntax different ?)

cheers,

–Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [June 17, 2009, 9:11am UTC](https://www.ruby-forum.com/t/flagged-enums/163833/8 "2009-06-17T09:11:18Z")

</div>

Hi,

This works now:

> > > > AnchorStyles.bottom | AnchorStyles.left
> 
> =\> Bottom, Left

thanks!

– Thibaut
