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 trial

iOS Swift Basics (retired) Collections What is an Array?

Tu Pham
Tu Pham
431 Points

why can't it be println("todo.count") but println(todo.count) only?

I'm still confused when something needs to be inside " " and when not

3 Answers

Joe Dayvie
Joe Dayvie
11,956 Points

Tu,

Quotes are used to String arguments. Since println() is not printing a String, it does not need quotes. If you wanted to do:

println("Tom")

Then you would place the quotes but you are calling the .count method so quotes are unnecessary. I am new to this myself so I hope that makes sense :P

Alejandro Crespo
Alejandro Crespo
6,628 Points

If you put it inside the quotation marks it will read it as a string while if you dont put it inside the marks then it will read it as a variable. For example if i say int four = 4; and say println("four"); it will print out "four." Meanwhile if I say println(four); it will print out "4" because since I didnt put it in quotation marks and it will look for the variable fourand print out its value which is "4".

Tu Pham
Tu Pham
431 Points

thank you for your answers ! i've think i get it now! ^^

Joe Dayvie
Joe Dayvie
11,956 Points

Tu,

You are most welcome =)

Joe