Re:Introducing Swift
by VeejayRampay on Monday June 02, 2014 @07:10PM
(#7837096)
I saw a lot of people mention ADT in relation to Swift but I haven't found examples in the documentation book I downloaded from Apple. Would you be kind enough to provide the example you saw?
EDIT: My bad, page 40 in the section about protocols (unless I'm missing something).
[ Parent
| on HN ]
It's on the bottom half of the page about enumerations. Typically languages have product types, but lack true sum types. Swift's enums provide such leverage.
That said, Swift's types are a bit less than recursive, so there's a bit of niggling still before you get to the affordances of something like Haskell's `data`.
Re:Introducing Swift
by VeejayRampay on Tuesday June 03, 2014 @12:06PM
(#7841000)
Thank you.