Getting error messages on
let answer = randomIntBetween(0, 100) - 'Missing argument label âhigh:â in call
and
let inputAsInt = userInput.toInt() - "toInt is unavailable:Use int() initializer
One thing I have noticed in most of the tutorials on here is that you always have these supporting files and sometimes there are quite a few. Like this tutorial you just gloss over the arc4random thing which allows you to make this app and without it all the code is trash. I look at this and it does me no good. You donât explain that supporting page at all and if you donât understand that page you could never recreate this not even close.
Thatâs really helpful to know. Often times, we make assumptions when creating tutorials and sometimes forget about the target assumptions. Iâll make sure to keep your comments in mind as well as pass them off to the rest of the team.
Hi tamidkmo ⊠Yeup, your approach would work great. In face, I would consider it the preferred approach. When we update the tutorial, Iâll make sure to incorporate your change.
One small note though. If you scroll down a little from the part âImplementing Roundsâ you say: Your file should now look like this:
When you look at the script itâs already the entire end product. So I got confused that I maybe forgot some stuff.
Can you elaborate on why his approach is better? Is it simply removing verbose code? In the original code are we assigning âinputAsIntâ to the value that the user inputs to the screen only to assign the optional âguessâ the value of âinputAsIntâ? In the âif let guess = Int(userInput)â statement you are just doing both in one statement correct? Thank you
hey Ray ⊠iâm glad i found such an amazing tutorialâŠ
i am on part 2 and i canât access the helper file for method randominbetween() idk whyâŠ
if you or anyone can send to my email it fdalthaqeel@gmail.com
will be so helpful. cause i canât continue without it.
Iâm not sure what is going on ⊠Iâm able to download the file without any issues. You can download the completed project at the end of the tutorial. Itâll contain the helper file in the project.
In the âImplementing Roundsâ section, the second block of code right after âYour file should now look like this:â has additions that you have not gone over yet. Such as adding var turn = 1, break, continue, turn = turn + 1
I believe that block of code should look like
import Foundation
let answer = randomIntBetween(0, high: 100)
while(true) {
print(âEnter a number between 1 and 100.â)
let userInput = input()
let inputAsInt = Int(userInput)
if let guess = inputAsInt {
if(guess > answer) {
print(âLower!â)
} else if(guess < answer) {
print(âHigher!â)
} else {
print(âCorrect! The answer was (answer).â)
}
} else {
print(âInvalid input! Please enter a number.â)
}
}
Itâs not a huge deal, but I was a little confused that I was told something should look a way and it didnât. I hope thatâs helpful!