Re: [swift-users] Removed discussions in doc for Swift 4. Why?

2017-06-12 Thread Erica Sadun via swift-users
`var` arguments were also removed -- E > On Jun 12, 2017, at 12:37 PM, Austin Zheng via swift-users > wrote: > > The currying syntax was removed in Swift 3 (see > https://github.com/apple/swift-evolution/blob/master/proposals/0002-remove-currying.md > >

Re: [swift-users] optional variable with ternary operator

2017-05-08 Thread Erica Sadun via swift-users
I believe this falls under "future directions" for comparison reform. Here's an example of a short term solution: https://gist.github.com/erica/77b110e17e51dbea7d6934e6582f627f -- E, who moved this from SE to Swift Users > On Ma

[swift-users] inline best practices?

2017-03-02 Thread Erica Sadun via swift-users
Any best practices for `@inline(__always)`? When it's short? When has very few call sites? When the abstraction aids reading but hinders computation? Thanks -- E ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinf

Re: [swift-users] [swift-evolution] for-else syntax

2017-02-02 Thread Erica Sadun via swift-users
I've taken this over to Swift Users from Swift Evolution. I think you'd want to handle the exceptional case first, as it provides an opportunity for early exit before processing normal behavior. In such case, consider using a guard rather than an if: guard !names.isEmpty else { print("No names"

Re: [swift-users] Issue with Sample Playgrounds (Sample Code)

2016-11-07 Thread Erica Sadun via swift-users
You encountered issues because that's a playground book and not a playground. It's meant solely for the iOS Swift Playgrounds app. -- E > On Nov 7, 2016, at 7:49 AM, Shyamal Chandra via swift-users > wrote: > > Hi, > > I couldn't get this zipped file [ Playgrounds-Starter-Book.zip ] to open

Re: [swift-users] The value of enums

2016-11-06 Thread Erica Sadun via swift-users
> On Nov 6, 2016, at 4:07 AM, Tino Heth via swift-users > wrote: > > Enums are a fundamental part of Swift, so I guess they won't change much — > but I wonder if anyone shares my observations in real-life use… > > Afair, there are three different types of enums: > - Enums with raw values > -

Re: [swift-users] hashValue of enum cases (was Reducing Array to OptionSet)

2016-11-04 Thread Erica Sadun via swift-users
It is absolutely an implementation detail and one you should never rely upon! — Erica Sent from my iPhone > On Nov 4, 2016, at 2:17 PM, Fritz Anderson wrote: > >> On 3 Nov 2016, at 8:37 PM, Erica Sadun via swift-users >> wrote: >> >> private enum Stri

Re: [swift-users] Reducing Array to OptionSet

2016-11-03 Thread Erica Sadun via swift-users
How about func joinOptionSets(_ sets: [OS]) -> OS { return sets.reduce([] as OS) { (result, set) in return result.union(set) } } joinOptionSets(sets).rawValue -- E > On Nov 3, 2016, at 7:48 PM, Erica Sadun via swift-users > wrote: > > Like this? > > l

Re: [swift-users] Reducing Array to OptionSet

2016-11-03 Thread Erica Sadun via swift-users
Like this? let sets: [MyOptionSet] = [MyOptionSet(strings: ["one"]), MyOptionSet(strings: ["two"]), MyOptionSet(strings: ["one", "two"])] let unioned = sets.reduce(MyOptionSet(rawValue: 0)) { (result, set) in return result.union(set) } unioned.rawValue > On Nov 3, 2016, at 7:44 PM, Jon Shie

Re: [swift-users] Reducing Array to OptionSet

2016-11-03 Thread Erica Sadun via swift-users
Maybe something like this? Or you could just bitwise || individual sets. Or you could use a dictionary to lookup [string: rawValue]. etc. public struct MyOptionSet: OptionSet { public static let one = MyOptionSet(rawValue: 1 << 0) public static let two = MyOptionSet(rawValue: 1 << 1)

Re: [swift-users] Monorepo workflow using SPM

2016-11-03 Thread Erica Sadun via swift-users
I want less of a monorepo than an ability to build a group of orthogonal elements into a single repo so I don't have to create a separate repo for every single Swift library I build, especially when there are logical relationships between subfolders and partial incorporation into builds For exa

[swift-users] Argument labels

2016-10-10 Thread Erica Sadun via swift-users
This goes beyond type significance as far as I can tell. Bug report? -- E enum Sample { case foo(Int), bar(label: Int) } let aFoo: Sample = .foo(1) let aBar: Sample = .bar(label: 1) // requires label if case let .foo(value) = aFoo { print(value) } // works if case let .bar(value) = aBar { pri

Re: [swift-users] [swift-evolution] Conditional casting and conditional binding: Wierd edge case or flawed design

2016-10-10 Thread Erica Sadun via swift-users
> On Oct 10, 2016, at 11:08 AM, Joe Groff wrote: > > >> On Oct 9, 2016, at 1:10 PM, Erica Sadun via swift-evolution >> mailto:swift-evolut...@swift.org>> wrote: >> >> Normally in guard and if condition lists, you look up a value in a >> dictionary and conditionally cast: >> >> if let va

Re: [swift-users] Creating a NSAttributedString from HTML

2016-09-15 Thread Erica Sadun via swift-users
> On Sep 14, 2016, at 9:43 AM, Félix Cloutier via swift-users > wrote: > > I'm trying to create a NSAttributedString from its HTML representation in > Swift 3 (from the Xcode 8 GM build). However, this doesn't work: > >> import Foundation >> import AppKit >> >> let html = "hello world" >> let

Re: [swift-users] Swift Playgrounds Not Included with iiOS 10.0.1 GM

2016-09-08 Thread Erica Sadun via swift-users
after upgrading to GM through OTA. Mine free space is >>> 9.35GB. >>> >>> I think it can be easily explained. It is not a system app, it appeared in >>> beta just because it is easily for us to test. It will appear in App Store >>> when iOS 10 officia

Re: [swift-users] Swift Playgrounds Not Included with iiOS 10.0.1 GM

2016-09-08 Thread Erica Sadun via swift-users
It is still on my iPad. As far as I can tell (going by Twitter replies), if you had sufficient space for the upgrade (I had about 3.5 gb), it was not removed. I recommend filing a bug report at bugreport.apple.com -- E > On Sep 8, 2016, at 3:23 PM, Michael Sheav

Re: [swift-users] remove "Example" from multiline playground markup

2016-08-31 Thread Erica Sadun via swift-users
To the best of my knowledge, this is a rendering choice made by the playground team and you cannot suppress it. Workaround: Use `whatever` code voice instead of code fencing. Playground markup is currently out of step with commonmark 0.25, which allows you to use a subset of raw HTML including

Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Erica Sadun via swift-users
And Greg from Omni Group has an even better solution for you. Since DateFormatter inherits from Formatter, you can use its `string(for:)` which accepts optionals: let dobString3 = serverDateFormatter.string(for:dob) ?? "" -- E > On Aug 4, 2016, at 3:17 PM, Erica Sadun vi

Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Erica Sadun via swift-users
> On Aug 4, 2016, at 1:41 PM, Tim Vermeulen via swift-users > wrote: > > You want `flatMap`: > > let dobString = dob.flatMap(serverDateFormatter.stringFromDate) > > Or if you want `dobString` to be non-optional: > > let dobString = dob.flatMap(serverDateFormatter.stringFromDate) ?? “" You c

Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Erica Sadun via swift-users
> On Aug 4, 2016, at 11:32 AM, Daniel Tartaglia via swift-users > wrote: > > Currently I do stuff like this: > > let dobString: String > if let dob = dob { > dobString = serverDateFormatter.stringFromDate(dob) > } > else { > dobString = "" > } > > Is there a better, more idiomatic

Re: [swift-users] Toolchain 07/29

2016-08-01 Thread Erica Sadun via swift-users
7/25 does not work for me. -- E > On Aug 1, 2016, at 10:51 AM, Charles Lane wrote: > > The 7/25 snapshot seems to work. That was before AnyObject was changed to Any. > > Regards, > Charles Lane > > >> On Aug 1, 2016, at 11:17 AM, Erica Sadun wrote: >> >> What is the most recent snapshot tha

Re: [swift-users] Toolchain 07/29

2016-08-01 Thread Erica Sadun via swift-users
What is the most recent snapshot that will actually work and compile code? 7/29 and 7/28 both fail for me. Thanks! -- Erica > On Jul 31, 2016, at 4:19 PM, Charles Lane via swift-users > wrote: > > Bug report SR-2234 has been filed. > > Thanks > > >> On Jul 31, 2016, at 4:38 PM, Mark Lace

Re: [swift-users] [swift-evolution] Multi dimensional - iterator, Iterator2D, Iterator3D

2016-07-31 Thread Erica Sadun via swift-users
I'm replying on Swift-Users and bcc'ing in Swift-Evolution to comply with the core team's request to focus SE on the current mission statement. At some point soon, Russ Bishop's PR https://github.com/apple/swift/pull/3600 will be incorporated into Swif

Re: [swift-users] Why unary ++ operator has been deprecated?

2016-07-04 Thread Erica Sadun via swift-users
> On Jul 4, 2016, at 8:32 AM, Martin Delille via swift-users > wrote: > > Everything is in the title. Everything to explain why should be in the formal proposal: https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md -- E __

Re: [swift-users] Clarification on the role of `CustomStringConvertible`

2016-06-29 Thread Erica Sadun via swift-users
On Jun 29, 2016, at 2:33 PM, Daniel Dunbar via swift-users wrote: > > I would like some clarification regarding the expected role of > `CustomStringConvertible` for types which have a natural, lossless, string > representation. And this is why we started down the road towards clarifying that

Re: [swift-users] Simplify chained calls

2016-06-28 Thread Erica Sadun via swift-users
> > On Jun 28, 2016, at 8:18 PM, Dan Loewenherz via swift-users > wrote: > > I’m not sure if you wanted to stick with the pure functional approach, but > here’s an alternative that uses Range to take care of most of the work. > > func selectionSort(_ array: [Int]) -> [Int] { > guard let m

Re: [swift-users] Porting Swift 2.2 to Swift 3.0

2016-06-23 Thread Erica Sadun via swift-users
> On Jun 23, 2016, at 9:04 PM, Ryan Lovelett via swift-users > wrote: > > extension Dictionary { >init(pairs: S) { >self.init() >for (key, value) in pairs { >self[key] = value >} >} > } > > let foo = ["Lorem", "ipsum"] > let bar = ["dolor", "sit"] >

Re: [swift-users] expression too complex

2016-06-16 Thread Erica Sadun via swift-users
func foo () -> Bool { return Double((pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x)) < 0.0 } See if that works and then file a bug report? -- E > On Jun 16, 2016, at 2:59 PM, Dave Reed via swift-users > wrote: > > > Joe, > > I had an expression that worked fine with Swif

Re: [swift-users] expression too complex

2016-06-06 Thread Erica Sadun via swift-users
I've seen this happen specifically in collections. There was one only yesterday that I was helping out with: http://i.imgur.com/tKh9On6.jpg Try doing this with all the String:Closure pairs in the original declaration. -- E > On Jun 6, 2016, at 4:15 PM, Joe G

Re: [swift-users] String Comparisons in Swift

2016-06-02 Thread Erica Sadun via swift-users
> On Jun 2, 2016, at 1:07 PM, John Myers via swift-users > wrote: > > I've had some difficulty comparing string variables to string constants with > ==. I believe it's always after using a readLine(). Does Swift require a > .equals() or a .compareTo(), as other c like languages, or are ther

Re: [swift-users] [Swift 3.0 Preview] Can't Convert to Latest Swift Syntax

2016-06-01 Thread Erica Sadun via swift-users
I really need to do a regular open source clinic post: send in up to 30 or 40 standalone lines that compile under 2.2 and won't under 3, with a description of expected behavior and test cases. You can reach out for help on irc.freenode.net in #swift-lang, there are several peer-support slack ch

Re: [swift-users] Coding style for internal/private variables

2016-06-01 Thread Erica Sadun via swift-users
>From what I've observed, preceding (rather than trailing) single underscores >indicate private use. The standard library includes a fair number of "Apple >Internal" (I guess now "Swift Team Internal") variables, methods, functions, >etc that follow this practice. This practice is, as far as I c

Re: [swift-users] Wrapping function declarations in #if swift()

2016-05-13 Thread Erica Sadun via swift-users
> On May 12, 2016, at 11:38 PM, Tyler Fleming Cloutier via swift-users > wrote: > > Hello everyone, > > It does seem like it is currently possible to wrap just the function > declaration in an #if swift() directive like so: > > #if swift(>=3.0) > public func add(filter filterName: String, pa

Re: [swift-users] Can't declare variable with same name as func called to assign its initial value

2016-05-12 Thread Erica Sadun via swift-users
> On May 12, 2016, at 1:07 PM, Evan Maloney via swift-users > wrote: > > Adopting the newer Swift style of preferring first parameter labels, I wrote > a function: > >func sale(options options: DeepLinkOptions) >throws >-> Sale >{ >// ...implementation... >}

Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Erica Sadun via swift-users
> >> On May 11, 2016, at 9:57 AM, Dennis Weissmann > > wrote: >> >> Huh! There’s a new overload for that initializer: >> >> >> >> The one that takes CGFloats is the one that was there before, but the one >> taking Floats is new! >> >> You can work around lik

Re: [swift-users] Guarding against an empty sequence

2016-05-09 Thread Erica Sadun via swift-users
I know this is completely not answering your question, but why wouldn't an empty sequence return true? There is no element in an empty sequence that does not satisfy the predicate. As for guarding against an empty sequence, you can create a buffered sequence type with 1-lookahead. Off the top o

Re: [swift-users] Trying to learn swift 3 renamification (as mattn calls it!)

2016-04-21 Thread Erica Sadun via swift-users
> On Apr 21, 2016, at 4:37 PM, Neil Faiman via swift-users > wrote: > > >> On Apr 21, 2016, at 5:50 PM, Charles Lane via swift-users >> wrote: >> >> Xcode wants to insert a comma between the words ‘with rect:’ for some reason. > > Is that a two-word parameter “name”, or is it just a parame

Re: [swift-users] Trying to learn swift 3 renamification (as mattn calls it!)

2016-04-21 Thread Erica Sadun via swift-users
> On Apr 21, 2016, at 2:23 PM, Ryan Lovelett wrote: > > On Thu, Apr 21, 2016, at 04:13 PM, Erica Sadun wrote: >> >>> On Apr 21, 2016, at 2:05 PM, Ryan Lovelett >> <mailto:swift-...@ryan.lovelett.me>> wrote: >>> >>> On Thu, Apr

Re: [swift-users] Trying to learn swift 3 renamification (as mattn calls it!)

2016-04-21 Thread Erica Sadun via swift-users
> On Apr 21, 2016, at 2:05 PM, Ryan Lovelett wrote: > > On Thu, Apr 21, 2016, at 03:50 PM, Erica Sadun via swift-users wrote: >> >>> On Apr 21, 2016, at 12:57 PM, Charles Lane via swift-users >>> mailto:swift-users@swift.org>> wrote: >>>

Re: [swift-users] Trying to learn swift 3 renamification (as mattn calls it!)

2016-04-21 Thread Erica Sadun via swift-users
> On Apr 21, 2016, at 12:57 PM, Charles Lane via swift-users > wrote: > > While rebuilding some apps using the new development trunk build, I figured > out the naming changes to just about everything but this: > > let string = "Here is a string" > > string.drawWithRect(CGRect(x

Re: [swift-users] ?? operator question

2016-04-18 Thread Erica Sadun via swift-users
> On Apr 18, 2016, at 7:23 AM, zh ao via swift-users > wrote: > > I do think there is something wrong here. > > // Xcode 7.3.1, Swift 2.2 > > let t1: Int? = 2 // struct Int? > let y = t1 ?? "abcdf" // error > let x = t1 ?? NSFont(name: "", size: 0) // x: NSObject? > > for x, how could it be

Re: [swift-users] [swift-evolution] What about a VBA style with Statement?

2016-04-13 Thread Erica Sadun via swift-users
> On Apr 13, 2016, at 9:26 AM, Sean Heber wrote: > >> On Apr 13, 2016, at 10:08 AM, Erica Sadun wrote: >> >> >>> On Apr 13, 2016, at 8:25 AM, Sean Heber via swift-evolution >>> wrote: >>> >>> This pair works pretty well, too, if you don’t mind free functions: >>> >>> func with(inout this:

Re: [swift-users] [swift-evolution] What about a VBA style with Statement?

2016-04-13 Thread Erica Sadun via swift-users
> On Apr 13, 2016, at 8:25 AM, Sean Heber via swift-evolution > wrote: > > This pair works pretty well, too, if you don’t mind free functions: > > func with(inout this: T, @noescape using: inout T->Void) { using(&this) } > func with(this: T, @noescape using: T->Void) { using(this) } > > It wo

Re: [swift-users] [swift-evolution] Requesting default values for Cocoa/Cocoa Touch APIs

2016-04-12 Thread Erica Sadun via swift-users
> On Apr 11, 2016, at 4:32 PM, Dave Abrahams via swift-evolution > wrote: > > > on Mon Apr 11 2016, Russ Bishop wrote: > >> Wouldn’t this be the responsibility of UIKit/AppKit teams to provide >> extensions >> that pass the default values? > > Yup. Please file radars against those compone

Re: [swift-users] Sampling collections

2016-04-10 Thread Erica Sadun via swift-users
> On Apr 10, 2016, at 2:39 PM, Milos Rankovic > wrote: > >> On 10 Apr 2016, at 21:23, Erica Sadun > > wrote: >> >> I do not think it's the role of a core language to worry about things like >> distributions, bias, and sampling. > > Why do you mention “the role of

Re: [swift-users] Sampling collections

2016-04-10 Thread Erica Sadun via swift-users
> On Apr 10, 2016, at 2:00 PM, Milos Rankovic via swift-users > wrote: > > Thank you, Jens, for your response. > > I do however disagree with both points you are making. First, you write that > sampling collection elements at random is: > >> a pretty obscure feature > > > But how can this

Re: [swift-users] Looping through all values between UInt8.min and UInt8.max

2016-04-08 Thread Erica Sadun via swift-users
It's a really good corner case to consider if you're thinking about redesigning ranges though. -- E > On Apr 8, 2016, at 8:43 AM, Nate Cook wrote: > > You can stride through the maximum value of a type if you land right on it: > > for i in UInt8.min.stride(through: UInt8.max, by: 1) { > pr

Re: [swift-users] Looping through all values between UInt8.min and UInt8.max

2016-04-08 Thread Erica Sadun via swift-users
> On Apr 8, 2016, at 3:48 AM, tuuranton--- via swift-users > wrote: > > print(UInt8.min) //0 > > print(UInt8.max) //255 > > > > //Is there an easy way to loop between all values > > //between (and including both) UInt8.min and UInt8.max? > > > > //This doesn't work. > > //Runtime crash

Re: [swift-users] pattern matching in if improvement?

2016-03-26 Thread Erica Sadun via swift-users
> On Mar 26, 2016, at 3:47 PM, Maury Markowitz via swift-users > wrote: > > Before I stick my head into the other list, consider: > > if statusCode >= 200 && statusCode <= 299 > > I'm sure examples of something like this occur throughout your code. But the > actual semantics of the test is

Re: [swift-users] Prototyping what Swift can look like in educational settings

2016-01-06 Thread Erica Sadun via swift-users
With regard to bullet 3, playgrounds vastly improve performance when you move code into Sources: http://ericasadun.com/2015/03/16/swift-vroom-vroom-fast-playgrounds/ (but then you can't see the code or tweak it *in* the play

Re: [swift-users] Prototyping what Swift can look like in educational settings

2016-01-06 Thread Erica Sadun via swift-users
Don, I love your playground. This highlights a few areas where I really would love to see some enhancements from the playground team. Here are a few off the top of my head. My actual list is longer: * Your students should be able to have an appropriate input and submission component that isn't

Re: [swift-users] In pursuit to a more idiomatic Swift

2016-01-04 Thread Erica Sadun via swift-users
Funny you should ask: Migrating `if`s to `guard`s in Swift https://medium.com/swift-programming/why-swift-guard-should-be-avoided-484cfc2603c5

Re: [swift-users] Lazily populated dictionary

2015-12-28 Thread Erica Sadun via swift-users
Maybe something like this? struct KeyedLazyCache { var backingDictionary: Dictionary var builderDictionary: Dictionary U> mutating func clear() {backingDictionary.removeAll()} mutating func valueForKey(key: T) -> U? { if let value = backingDictionary[key] {return value}

[swift-users] Going a little crazy with the Swift Package Manager

2015-12-28 Thread Erica Sadun via swift-users
If anyone could kick the wheels and/or give feedback: SwiftString (should be okay on apple and linux) SwiftUtility (should be okay for apple and linux) SwiftFoundationAdditions

Re: [swift-users] Setting up properties

2015-12-21 Thread Erica Sadun via swift-users
Thanks again! -- E,passed on > On Dec 21, 2015, at 8:15 PM, David Turnbull via swift-users > wrote: > > You could be lazy about it... > lazy private(set) var derp: Bool = { > [unowned self] in > return self._findDerp() != nil > }() _

Re: [swift-users] Setting up properties

2015-12-21 Thread Erica Sadun via swift-users
Thanks. Passed that along back. -- E > On Dec 21, 2015, at 7:47 PM, Joe Groff wrote: > > Yeah, instance methods can't be called until `self` is fully initialized, > since they may themselves touch the uninitialized instance. In addition to > making the function global, you could also make it

[swift-users] Setting up properties

2015-12-21 Thread Erica Sadun via swift-users
For a friend: This won't work. class DerpController { private(set) var derp: Bool = { return _findDerp() != nil }() private func _findDerp() -> AnyObject? { return nil } } but this works: private func _findDerp() -> AnyObject? { return nil } class Der

Re: [swift-users] Need better name, want to hide generator

2015-12-19 Thread Erica Sadun via swift-users
Here's what I ended up with. (The use-case for this ended up being light-weight game tile placement, not image processing or anything. ) func cartesianProduct(s1: S1, _ s2: S2) -> AnySequence<(S1.Generator.Element, S2.Generator.Element)> { let items = s1.lazy.flatMap({ item1 in s2.la

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
ere ProductSequence.Generator.Element is (T, U). >> >> So your example could be "for (x,y) in product(0..<4, 0..<2)". >> >> Jacob Bandes-Storch >> >> On Fri, Dec 18, 2015 at 1:22 PM, Erica Sadun via swift-users >> mailto:swift-users@swift.or

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
gt; ... > } > > where ProductSequence.Generator.Element is (T, U). > > So your example could be "for (x,y) in product(0..<4, 0..<2)". > > Jacob Bandes-Storch > > On Fri, Dec 18, 2015 at 1:22 PM, Erica Sadun via swift-users > mailto:swift-users

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
t; I'd love to see something like this in stdlib: > > func product(s1: S1, s2: S2) -> ProductSequence S2.Generator.Element> { > ... > } > > where ProductSequence.Generator.Element is (T, U). > > So your example could be "for (x,y) in product(0..<

[swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
Source: http://swiftstub.com/788132715 Two questions: 1. Can anyone recommended a better name than Cartesian? 2D doesn't work for the compiler and I'm looking for something that doesn't seem "floating-point"-y 2. Is there a way to internalize the generator and no

Re: [swift-users] Using Swift for interpreted shell scripts?

2015-12-15 Thread Erica Sadun via swift-users
I've given up on it. I find it far easier to just write a command-line app with Xcode's source support -- E > On Dec 15, 2015, at 12:45 PM, @lbutlr via swift-users > wrote: > > Are there any resources on using swift for shell scripting? > > I’m interested in trying my hand at Swift by convert

Re: [swift-users] Swift BMI

2015-12-15 Thread Erica Sadun via swift-users
e check since the switch that is used to >> initialise the enum value is exhaustive. >> >> http://swiftstub.com/242291010/ <http://swiftstub.com/242291010/> >> >> On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users >> mailto:swift-users@swift.org

Re: [swift-users] Swift BMI

2015-12-15 Thread Erica Sadun via swift-users
//swiftstub.com/242291010/> > > On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users > mailto:swift-users@swift.org>> wrote: > Leaving aside typos, any discussion about the merits of BMI, and the > intemperate language in the code, you do a few things that could

Re: [swift-users] For loop question?

2015-12-15 Thread Erica Sadun via swift-users
Let me add that stride offers two variations: "to" and "through", which you can see here: http://swiftstub.com/102043338 The to variation documentation states: /// Return the sequence of values (`self`, `self + stride`, `self + /// stride + stride`, ... *last*) where *last* is the last

Re: [swift-users] Swift BMI

2015-12-15 Thread Erica Sadun via swift-users
Leaving aside typos, any discussion about the merits of BMI, and the intemperate language in the code, you do a few things that could be improved upon language-wise. Of these, the most egregious is the final "break the machine" else statement that can never be reached. The following example doe