• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Swift question (From: Greg Weston <email@hidden>)

  • Prev by Date: Re: swift and objective-c
  • Next by Date: Re: Some non-obvious Swift goodies
  • Previous by thread: Re: Swift question
  • Next by thread: Swift JIT
  • Index(es):
    • Date
    • Thread