Earlier quoted context omitted.
I agree! Eithers are cool, too. What I'm really excited about is that these sorts of concepts are starting to find their way into languages like Swift. Getting built-in support for Eithers would be super awesome. In the meantime, you can vaguely simulate it with named tuples. let response = (error: "Could not connect to server", success: false) It's not quite the same, but at least there's an easy way to bundle your…
Other approach: use enums as union types. From https://developer.apple.com/library/ios/documentation/Swift/... : enum Barcode { case UPCA(Int, Int, Int, Int) case QRCode(String) } This can be read as: “Define an enumeration type called Barcode, which can take either a value of UPCA with an associated value of type (Int, Int, Int, Int), or a value of QRCode with an associated value of type String.” So, you can do enum…
A Video Walkthrough of Swift Fundamentals
11–20 of 20 posts
Re: A Video Walkthrough of Swift Fundamentals
#12This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…
>One of my favorite parts of Swift is the optional concept What if you need the fallback value to be an error possessing information about what went wrong? data Maybe a = Just a | Nothing data Either a b = Left a | Right b
Personally, I just want higher-kinded types, and for the following code snippets to work as-is:
enum Either {
case Left(A)
case Right(B)
}
enum Tree {
case Leaf
case Node(Tree, A, Tree)
}
The first breaks because of the "Unimplemented non-fixed multi-payload enum layout" compiler error, and the second breaks because enums have value semantics. Both can be worked around in full generality by declaring a 'Box' generic wrapper class, but that workaround is inelegant and cumbersome.Re: A Video Walkthrough of Swift Fundamentals
#13This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…
>One of my favorite parts of Swift is the optional concept What if you need the fallback value to be an error possessing information about what went wrong? data Maybe a = Just a | Nothing data Either a b = Left a | Right b
Re: A Video Walkthrough of Swift Fundamentals
#14Re: A Video Walkthrough of Swift Fundamentals
#15Re: A Video Walkthrough of Swift Fundamentals
#16This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…
Hello, While I do not have time to go over the whole video, surely you could have come up with much more serious reasons why Swift might be preferable to Objective C than "uhm, it has no namespaces and looks strange". Also, there were no reasons why "not to use Swift [yet]", making sure to mention the terrible state the developer tools are at this point, as well as many many missing language features and other quirks…
Terrible compared to something like a mature IDE like Visual Studio or Eclipse and/or an established toolchain.
Because compared to what most newcomer/not top-10 languages have (languages like D, Racket, Haskell and beyond) it's extremely impressive, especially considering the language is so young.
Re: A Video Walkthrough of Swift Fundamentals
#17This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…
Re: A Video Walkthrough of Swift Fundamentals
#18Re: A Video Walkthrough of Swift Fundamentals
#19Earlier quoted context omitted.
Hello, While I do not have time to go over the whole video, surely you could have come up with much more serious reasons why Swift might be preferable to Objective C than "uhm, it has no namespaces and looks strange". Also, there were no reasons why "not to use Swift [yet]", making sure to mention the terrible state the developer tools are at this point, as well as many many missing language features and other quirks…
> making sure to mention the terrible state the developer tools are at this point Terrible compared to something like a mature IDE like Visual Studio or Eclipse and/or an established toolchain. Because compared to what most newcomer/not top-10 languages have (languages like D, Racket, Haskell and beyond) it's extremely impressive, especially considering the language is so young.
Re: A Video Walkthrough of Swift Fundamentals
#20This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…