iOS Swift Basics An Introduction to Swift Programming Working With Variables

Ronald Todman
Ronald Todman
1,487 Points

Assigning the string called "Swift" to var "language" using the str = "Swift" but command but it is not link to var

Good Day everyone I am Assigning the string called "Swift" to var "language" using the str = "Swift" command but it is not linked. var str = "language" str = "Swift" I read the error code in which it pointed out adding ";" So I var str = "language" str ; "Swift "

Can someone point out where I went wrong? Thanks

variables.swift
// Enter your code below

var str = "language"
str = "swift"

3 Answers

tromben98
tromben98
13,273 Points

Good day Ronald!

The problem here is that you are not creating a variable named language instead you create a variable named str.

Here is the solution:

// Enter your code below
var language: String = "swift"
language = "Objective-C"
Ronald Todman
Ronald Todman
1,487 Points

Hi, Tromben, thanks for helping me figure this out, I tried what you recommended, but it did not work. Here is the question I am trying to solve, " Declare a variable named language and assign the string "Swift". We didn't go over the specific syntax for creating a String so remember to start with a double quote, write the word, and close it with a double quote."

Thanks

tromben98
tromben98
13,273 Points

I ran the challenge with my code and it worked for me. Paste in my code in the editor and it should work. Otherwise there might be a problem with your browser.

Ronald Todman
Ronald Todman
1,487 Points

I posted it in Xcode, it worked with no problem, I will take a look at my browser and make sure I am up to date.

var "notetoself: String = "Write the code in your swift program as well as the browser"

notetoself = "Thanks for the help"

Cheers :)