|
Meat Street posted:Possibly-stupid question: can I for-in iterate through an enum, e.g. the Suit enum in the card examples? It's a feature we've thought about. Feel like filing a bug to ask for it?
|
# ? Jun 3, 2014 05:39 |
|
|
# ? May 4, 2024 17:17 |
|
Can do! Let me know if you want the rdar ID once it's filed. As an aside, I just wrote my first (very simple) view controller in Swift and I'm ready to never look back. Great work, and thanks to you and your team. edit: filed, rdar://17102392 Meat Street fucked around with this message at 05:51 on Jun 3, 2014 |
# ? Jun 3, 2014 05:42 |
|
Meat Street posted:Can do! Let me know if you want the rdar ID once it's filed. Mind putting it up for comparisons sake?
|
# ? Jun 3, 2014 05:49 |
|
Sure: https://gist.github.com/tomburns/8975715cd4811d30417f Like I said, dead simple. But it works! Radar filed for the enum iteration and linked in my post above.
|
# ? Jun 3, 2014 05:53 |
|
Based on comments I've come across elsewhere on the Internet, it sounds like there are a lot of people with strong opinions about Swift, and they tend to be negative toward the language's design because of little things such as the range operators as noted above. You just can't win them all, I guess. (Frankly, I'm in the ".." includes the last number camp, mostly because I see that number as "standing in" for the last dot, but I can survive either way. It's something a good test should catch, if I get it wrong.) Tomorrow morning, when I can get back to Moscone (instead of dealing with lovely hotel Wi-Fi) I'm going to play around with the Unit Testing. Looking at the Swift documentation, I don't see any reference to private/public methods. Is everything public, or am I just missing something in the documentation?
|
# ? Jun 3, 2014 06:00 |
|
Axiem posted:Looking at the Swift documentation, I don't see any reference to private/public methods. Is everything public, or am I just missing something in the documentation? Everything is public for now. We expect to have basic access control for 1.0.
|
# ? Jun 3, 2014 06:06 |
|
rjmccall posted:Everything is public for now. We expect to have basic access control for 1.0. Ok cool, I came here to ask this. The lack of documentation about access control at all had me worried that the answer was "use a bunch of anonymous functions".
|
# ? Jun 3, 2014 07:35 |
|
quote:Methods on classes have one important difference from functions. Parameter names in functions are used only within the function, but parameters names in methods are also used when you call the method (except for the first parameter). By default, a method has the same name for its parameters when you call it and within the method itself. I'm curious about this distinction. Why not let function calls also include parameter names?
|
# ? Jun 3, 2014 08:00 |
|
I've been browsing the documentation and Swift looks pretty interesting. Just when I thought I was getting the hang of Objective-C though! So many languages to learn for mobile development.
|
# ? Jun 3, 2014 08:02 |
|
Axiem posted:Is Swift going to be supporting unit testing and the like? My workplace is thoroughly in the TDD camp (as am I), and having a language that really supports it would be fantastic. XCTest has basic support for Swift, including the new testing features announced today. If there's anything specific you'd like to see in the Swift testing experience we'd love to hear your thoughts on it.
|
# ? Jun 3, 2014 08:31 |
|
Siguy posted:I'm curious about this distinction. Why not let function calls also include parameter names? There are a couple different things in play here. First, there's value in all calls to the same entity looking consistent, as opposed to some using argument names and others not. A scripting language probably wouldn't care, but we do. That's probably not in flux. Second, there was a sense among some of us that native Swift declarations shouldn't feel completely different from imported C/ObjC declarations. ObjC methods have argument names, but C functions do not. I don't think I agree with this position, but it's where we are right now. This probably is in flux. You still can provide argument names for free functions (in which case they'll become required); they're just not the default.
|
# ? Jun 3, 2014 09:19 |
|
Super interesting thread. It's neat to see the thought that goes into designing a language that will be as important as Swift. My question is will we be able to get the string representation of enums?
|
# ? Jun 3, 2014 13:18 |
|
Whenever I looked into learning Obj-C, all the books pretty much said "Oh before you learn this, you REALLY should get your head around C first...". Is Swift developed so you can essentially go into it fresh? I've done basic stuff in Python and a few web scripts but never any C based languages and that always put me off making even basic apps for iOS. Also, presumably even though the keynotes were showing how well Swift lives alongside C and Obj-C, that's only really there for legacy purposes and Swift is all you'd actually need for fully featured apps, if that's the only language you want to use?
|
# ? Jun 3, 2014 13:42 |
|
EL BROMANCE posted:Whenever I looked into learning Obj-C, all the books pretty much said "Oh before you learn this, you REALLY should get your head around C first...". Is Swift developed so you can essentially go into it fresh? I've done basic stuff in Python and a few web scripts but never any C based languages and that always put me off making even basic apps for iOS. Swift doesn't sit on top of C like Obj-C does so you should be fine. It might even be easier if you don't know C since it diverges pretty significantly. I think that, from what's been said so far, you should be fine only knowing Swift for iOS development however there's a huge amount of open source code and libraries that you will lose out on if you cut out objective-c completely.
|
# ? Jun 3, 2014 14:05 |
|
At the moment trying to learn Swift without knowing Objective-C is probably not going to end well, but long term it seems perfectly reasonable to learn it without knowing C or Objective-C first, although you'll probably end up needing to know all three to write anything substantial.
|
# ? Jun 3, 2014 14:54 |
|
Plorkyeran posted:At the moment trying to learn Swift without knowing Objective-C is probably not going to end well, but long term it seems perfectly reasonable to learn it without knowing C or Objective-C first, although you'll probably end up needing to know all three to write anything substantial. I disagree. I think if your goal is to learn Swift you aren't going to get much benefit from trudging through ObjC. Plus the pedagogical advantage of learning in the Playground environment is fantastic.
|
# ? Jun 3, 2014 14:58 |
|
Flobbster posted:I'd love to see a language do something similar to a proper mathematical interval syntax for integral ranges. Factor does this, but like everything else the operators are postfix.
|
# ? Jun 3, 2014 15:06 |
|
lord funk posted:I disagree. I think if your goal is to learn Swift you aren't going to get much benefit from trudging through ObjC. Plus the pedagogical advantage of learning in the Playground environment is fantastic.
|
# ? Jun 3, 2014 15:12 |
|
Haven't finished reading the book yet... is there a way to inspect the type of a variable or constant in the playground? like ghc's :t
|
# ? Jun 3, 2014 15:49 |
|
Kind of a hack, but if you have the value as a variable and start typing its name, the autocomplete indicates its type.
|
# ? Jun 3, 2014 15:58 |
|
Plorkyeran posted:If your goal is to just learn Swift then sure, you won't need to ever learn objective-c once the docs are fully in place. If your goal is to actually write nontrivial apps in Swift, you'll need to know Objective-C at least well enough to debug issues when using Objective-C libraries. I look at it from the same perspective as what EL BROMANCE said about the books that insisted that you needed a solid C foundation. I skipped that when learning ObjC, and I work with old C frameworks like CoreAudio all the time. You just kind of look up what you need when you get there. I'm really excited for the talk about integrating Swift with ObjC. Question for rjmccall: will there be a Swift version of sets?
|
# ? Jun 3, 2014 15:59 |
|
Meat Street posted:Kind of a hack, but if you have the value as a variable and start typing its name, the autocomplete indicates its type. Thanks, this worked well enough that I figured out where my problem was. If you do a range subscript on an Array, you don't get an Array back. You get a Slice. They're not freely interchangeable. So if you want an Array, convert it with Array(names[0..5])
|
# ? Jun 3, 2014 16:10 |
|
eschaton posted:XCTest has basic support for Swift, including the new testing features announced today. If there's anything specific you'd like to see in the Swift testing experience we'd love to hear your thoughts on it. I'll play with it and see what I come up with. Is the best way to provide feedback to file Radars, or is there someway else?
|
# ? Jun 3, 2014 16:30 |
|
Filburt Shellbach posted:Haven't finished reading the book yet... is there a way to inspect the type of a variable or constant in the playground? like ghc's :t I'm not totally up on playgrounds, but IIRC, you can option-click on random things.
|
# ? Jun 3, 2014 16:35 |
|
lord funk posted:Question for rjmccall: will there be a Swift version of sets? Almost certainly.
|
# ? Jun 3, 2014 16:36 |
|
EngineerJoe posted:Super interesting thread. It's neat to see the thought that goes into designing a language that will be as important as Swift. My question is will we be able to get the string representation of enums? Yes, it's something we want to make easy to do.
|
# ? Jun 3, 2014 16:43 |
|
Flappy Bird in Swift: https://github.com/fullstackio/FlappySwift
|
# ? Jun 3, 2014 18:03 |
|
Axiem posted:there are a lot of people with strong opinions about Swift, and they tend to be negative toward the language's design because of little things
|
# ? Jun 3, 2014 18:12 |
|
Was/is there any relation between the language 'Swift' and the code name attributed to the CPU in the A6 SoC (also swift). IIRC A7 is Cyclone. 'yeah I'm working on swift right now' 'Sorry which division?' Seems like cross wires or a coincidence?
|
# ? Jun 3, 2014 18:34 |
|
I don't write code for my day job, so I'm much less knowledgeable than most of the people in this thread. I'm trying to get my head around optionals. At a high level, I think it's trying to prevent accidentally using a declared but uninitialized variable from crashing the program. So:code:
|
# ? Jun 3, 2014 18:42 |
|
Kobayashi posted:I don't write code for my day job, so I'm much less knowledgeable than most of the people in this thread. I'm trying to get my head around optionals. At a high level, I think it's trying to prevent accidentally using a declared but uninitialized variable from crashing the program. So: yes. You can think of String? as a class that can either have Some String or None. In most languages you have to do something like code:
code:
|
# ? Jun 3, 2014 19:15 |
|
Ocrassus posted:Was/is there any relation between the language 'Swift' and the code name attributed to the CPU in the A6 SoC (also swift). I'm pretty sure rjmccall mentioned it was a recent marketing name.
|
# ? Jun 3, 2014 19:25 |
|
EngineerJoe posted:Super interesting thread. It's neat to see the thought that goes into designing a language that will be as important as Swift. My question is will we be able to get the string representation of enums? Also can you add a deriving mechanism like Haskell so I don't have to reimplement stuff like equality and string representation + json serialization?
|
# ? Jun 3, 2014 19:34 |
|
Are there any documentation playgrounds in the shipping Xcode beta? I couldn't find the NSDateFormatter one mentioned in SotU.
|
# ? Jun 3, 2014 19:52 |
|
Malcolm XML posted:Also can you add a deriving mechanism like Haskell so I don't have to reimplement stuff like equality and string representation + json serialization? We want to, yes.
|
# ? Jun 3, 2014 20:13 |
|
So the only way for me to mess around with this language right now is paying $99 for a developer license?
|
# ? Jun 3, 2014 20:35 |
|
I'm sure it is politically difficult, but we really need a better way to communicate besides filing radars. I know you guys are eager to get feedback but there's a layer of beauracracy in between us that measures their self worth by how many radars they can close in a single day, or possibly deriving which misinterpretation will be the most anger-inducing*. I'm not saying this for your benefit obviously, I'm sure you'd have already released it and started a public discussion forum/mailing list if it were up to you.
|
# ? Jun 3, 2014 20:57 |
|
FamDav posted:whereas in swift, they effectively generate this logic for you when you do C# is supposed to be getting this syntax in its next version. In the meanwhile I'm liking what I'm tinkering with in Swift so far
|
# ? Jun 3, 2014 21:09 |
|
Swift code:
|
# ? Jun 3, 2014 21:46 |
|
|
# ? May 4, 2024 17:17 |
|
Doctor w-rw-rw- posted:Anyone else able to reproduce? Yep, crashed mine right away
|
# ? Jun 3, 2014 21:56 |