Home / Highlights / FAQ / Examples / Quick Start / Roadmap / Download / About Us
enum Fruit { Apple, Banana, Cherry }
bitflag FileBits { Read, Write, Execute, Reg=128, Block, Dir }

main()
{
	//We all know how enums work
	assert(Fruit.Apple == 0)
	assert(Fruit.Banana == 1)
	assert(Fruit.Cherry == 2)

	//Bitflags are more fun
	//assert(FileBits.None == 0)
	assert(FileBits.Read == 1)
	assert(FileBits.Write == 2)
	assert(FileBits.Execute == 4)
	assert(FileBits.Reg == 128)
	assert(FileBits.Block == 256)
	assert(FileBits.Dir == 512)

	a := Fruit.Apple
	b := FileBits.Read

	//Because the variable a and b have a type we can do this
	a .= Banana
	b .= Read

	//Params have types so we can also do
	assert(IsABanana(Banana))
	assert(!IsABanana(Cherry))

	//Relative compare works
	assert(a < Cherry)
	assert(b < Dir)

	//bitflag only feature. Result of an & is an acceptable bool
	b .= Read|Execute|Reg
	assert(b & Execute)
}

IsABanana(Fruit v) bool { return v == Banana }