Enumerations and Optionals: Intro to Enumerations (Part 2)
Continuing with Enums...really enjoying these so far! Associated Enums Pasan mentioned a 'wrapper' object...apparently we will find out more! In the example of a colour component enum, we need to provide associated enums...Adding in four float values in brackets - these four represent the rgb colour case. enum ColourCoomponent { case rgb ( Float , Float , Float , Float ) case hsb } The same needs to be done for the hsb case. So for each Enum member, there are parameters involved. Accessing them with the dot notation means they are properties? enum ColourCoomponent { case rgb ( Float , Float , Float , Float ) case hsb ( Float , Float , Float , Float ) } let colour = ColourCoomponent . hsb ( 55 , 77 , 91 , 109 ) Methods on Enumerations A point Pasan makes straight away is that an enum is not really an object - we don't create insta...