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 trialTu Pham
431 Pointswhy 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
11,956 PointsTu,
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
6,628 PointsIf 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
431 Pointsthank you for your answers ! i've think i get it now! ^^
Joe Dayvie
11,956 PointsTu,
You are most welcome =)
Joe