BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

xcode not showing up variable type when i use command to bring up ? mark

Forums > iOS

Any idea? It just says no documentation.

import Foundation

struct Game { var target: Int = Int.random(in: 1...100) var score: Int = 0 var round: Int = 1

func points(sliderValue) -> Int {
let difference = abs(target - sliderValue)

    // or difference*= -1
    // or difference = -difference
    let awardedPoints = 100 - difference
    return awardedPoints
}

}

difference is an int but its not showing up like this

   

You need to finish the function signature. Swift doesn't know what type sliderValue is. I'm guessing that should be an Int too?

(i.e. func points(sliderValue: Int) -> Int {)

   

Help us to help you!

Please put ALL of your code inside the markup tags. Some of your code is outside, and therefore not properly formatted.

Forum guru @roosterBoy made a great post about adding code to your forum message.

See-> How to post code

@linkbackticks
@linkmarkup

   

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.