Re: Swift question
Re: Swift question
- Subject: Re: Swift question
- From: Robert Lockstone <email@hidden>
- Date: Wed, 04 Jun 2014 20:24:06 -0700
Then maybe something like this?
func getTitle(amount: Integer, singularForm: String) -> String { return (amount == 1) ? singularForm : singularForm+"s" }
for amount in 1...3 { var nails = amount * 100 - 99 println("toolSummary: I have \(nails) \(getTitle(nails, "nail")) and (\amount) (\getTitle(amount, "hammer"))") }
Or something like that, haha.
Rob
On Jun 4, 2014, at 16:10 , Greg Weston < email@hidden> wrote: Much nicer.. but the same outcome - warning based on the value of hammers. Same, even if I use a variable to load hammers, as Ronald suggested.
The problem with this test is that the compiler is smart enough to see that within the snippet the value of hammers is deterministic. Good for real projects. Troublesome for playing and simple test cases.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden