Reputation: 119
I am new to swift and iOS programming and learning slowly here. So I have:
@IBOutlet weak var timeEntered: UITextField!
@IBAction func countDown(sender: AnyObject)
{
var total = timeEntered.text.toInt()
total = total *7
}
The line total = total *7
gives me the error "Consecutive statements on a line must be separated by a ;"
I read here that you should do ( I don't know why but...)
total = total! *7
And still I get the same error. Any help would be highly appreciated. Thanks!
Upvotes: 1
Views: 1689
Reputation: 52538
In Swift, operators like "*" must have either no space on either side of the operator, or white space on both sides of the operator.
That forces you to avoid ugliness like your
total = total *7
Write it nicely. Either of these:
total = total * 7
total = total*7
Now this:
total = total! *7
That's just grabbing around in the dark without any idea what you are doing. That's no way how to program. You must know why. How can you ever be sure what your code does when you don't know the why's?
Upvotes: 1
Reputation: 190
I think that you must separate the '*' and the '7'. Try this total = total * 7
Upvotes: 1