Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZachary Kinnear
Courses Plus Student 2,269 PointsHi I seem to have written the code and cannot see the issue could someone please help? Thanks.file:///Users/Zak/Desktop/
The image of the code is in the link.
let language = "Swift"
println["Learing Swift \ [language]"]
1 Answer
noreenqureshipowley
iOS Development Techdegree Student 1,096 PointsHi there,
I would like to point out a few things I noticed about your code.
I would first like to explain, that I used your example to answer a question for myself - what is the difference between using print and println in Swift. I had previously recalled that println would add a space after a print statement. However, looking at stackoverflow it seems Swift 2 no long uses println. My guess is you're using XCode for Swift 2.2. http://stackoverflow.com/questions/25951195/swift-print-vs-println-vs-nslog. Just to be sure I also verified this on the Apple Developer site https://developer.apple.com/library/ios/releasenotes/General/iOS90APIDiffs/Swift/Swift.html. You can search that page for println.
Second, I would suggest using parenthesis () with your code rather than brackets []. So far I have seen brackets only used with Arrays and Dictionaries, but I am a newbie too so there may be other uses. However, to make your print statement work, try using parenthesis.
Third, if I were to re-write your original statement, the result should have been "Learning Swift Swift." this is because in your String in print you wrote "Learning Swift" before interpolating your String type constant named language. This is your code:
//Your Code
let language = "Swift"
print("Learning Swift \(language)")
//This will print "Learning Swift Swift
As Kyle mentioned, you may want to re-write this as:
//New Code
let language = "Swift"
print("Learning \(language)")
//This will print "Learning Swift
Or even:
//New Code 2
let language = "swiftly"
print("Learning Swift \(language)")
//This will print "Learning Swift
Congrats, and here's to newbies learning Swift!
Zachary Kinnear
Courses Plus Student 2,269 PointsThanks You so much!!!!
Kyle Lambert
1,969 PointsKyle Lambert
1,969 PointsThis should help you out :)