|
So is there a way to explicitly define a main() entry point for a program written in Swift? The iBook that's available online doesn't specify anything (it just says that stuff in global scope gets executed first) and I don't have access to the Betas so I can play around.
|
# ¿ Jun 4, 2014 15:36 |
|
|
# ¿ May 4, 2024 18:58 |
|
This is an exception-al () writeup. Thank you. If I'm reading this correctly, this will also handle nested try calls with rethrowing, correct? Also, does Swift allow C-style typedefs? Those try function signatures look like brainfuck at first glance.
|
# ¿ Jun 8, 2014 10:29 |
|
So doesn't Xcode 6 support creating a Swift app for OS X through the new project wizard? I get the option for iOS apps but not for OSX...
|
# ¿ Oct 21, 2014 02:44 |
|
pokeyman posted:Xcode 6.1 brings Swift to OS X. Check the App Store for an update! Doh...that makes sense.
|
# ¿ Oct 21, 2014 07:14 |
|
So I've decided to get back into Swift since I've got some time on my hands. Maybe this eluded me the first time around but is there no way to tag methods (for classes) as non-mutating to the instance's state? Basically I'm trying to understand if there exists a mechanism similar to C++'s "const".
|
# ¿ Jun 19, 2015 07:28 |
|
Flobbster posted:If you use structs instead of classes, then you get what you want the opposite way: all methods are "const" (non-mutating) unless you specify the mutating keyword. This won't help if you're forced to use classes, though (e.g., if you're inheriting from a framework class). Thanks for the reply! I was aware of that but obviously structs have other tradeoffs. It would be interesting to hear the motivation behind such a design choice (paging rjmccall). e: "defer" is the most beautiful language feature I have ever seen in my entire life. shodanjr_gr fucked around with this message at 08:35 on Jun 19, 2015 |
# ¿ Jun 19, 2015 07:53 |
|
Dessert Rose posted:Seriously. Such an elegant solution to the problem. Indeed! And from messing around in Playgrounds, it seems that you can have multiple of them within a scope and they get executed in sequence when you bail out. Which makes them even more awesome. I really appreciate the very detailed response and I can understand that properly enforcing const-correctness imposes some (non-trivial) overhead to developers which leads a lot of folks to cut corners and/or not do it right. So from what I gather, the only way (currently) for the compiler to enforce non-mutation is to use structs and "eat" the value-type overhead?
|
# ¿ Jun 19, 2015 22:50 |
|
|
# ¿ May 4, 2024 18:58 |
|
Quick question on doing interval matching in a switch statement:code:
|
# ¿ Jun 23, 2015 09:14 |