# \- set default to an enum type

**URL:** <https://community.zeek.org/t/set-default-to-an-enum-type/5743>\
**Category:** Zeek\
**Created:** [June 23, 2019, 12:20pm UTC](https://community.zeek.org/t/set-default-to-an-enum-type/5743 "2019-06-23T12:20:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![william\_de\_ping](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@william\_de\_ping](https://community.zeek.org/u/william_de_ping)\
**Post date:** [June 23, 2019, 12:20pm UTC](https://community.zeek.org/t/set-default-to-an-enum-type/5743/1 "2019-06-23T12:20:23Z")

</div>

Hi everyone,

I have a variable that has &optional &default attributes.  
I want the &default attribute to have a value of an enum.

So if the enum is : type color: enum { Red, White, Blue, };  
c: color &default=Red;

Does not work…

Any ideas on the correct syntax ?

Thank you  
B

---

<div class="post-metadata">

**Author:** ![JustinAzoff](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@JustinAzoff](https://community.zeek.org/u/JustinAzoff)\
**Post date:** [June 23, 2019, 3:07pm UTC](https://community.zeek.org/t/set-default-to-an-enum-type/5743/2 "2019-06-23T15:07:02Z")

</div>

That is the correct syntax.

[http://try.bro.org/#/trybro/saved/334009](http://try.bro.org/#/trybro/saved/334009)

$ cat color.bro  
type Color: enum {Red, Green, Blue};  
type Whatever: record {  
&nbsp;&nbsp;&nbsp;&nbsp;color: Color &default=Red;  
};

event bro\_init()  
{  
&nbsp;&nbsp;&nbsp;&nbsp;local t: Whatever;  
&nbsp;&nbsp;&nbsp;&nbsp;print t$color;  
}

$ bro color.bro  
Red

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:46pm UTC](https://community.zeek.org/t/set-default-to-an-enum-type/5743/3 "2022-05-06T15:46:35Z")

</div>


