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 trialVladimir Vasconcelos
Courses Plus Student 6,433 PointsWhat am I doing wrong?
I think my code is ok, but I'm still getting an error.
public fun PictureBook(){
var title : String = "Android Adventures"
}
3 Answers
Seth Kroger
56,414 PointsYou should be using class
instead of fun
.
Todd Anderson
4,260 PointsTry var title = "Android Adventures";
:)
Vladimir Vasconcelos
Courses Plus Student 6,433 Pointspublic fun PictureBook(){
var title = "Android Adventures"
}
I got:
Bummer! Make sure PictureBook has a 'title' property and that it's a String
Todd Anderson
4,260 PointsHmm... Mine passes. I do notice you forgot the semi-colon after "Android Adventures";
public class PictureBook(){
var title = "Android Adventures";
}
Raveesh Agarwal
2,994 Pointsno. in Kotlin, "; " is not required always use val where possible. Declare var only when you absolutely need to
Raveesh Agarwal
2,994 PointsRaveesh Agarwal
2,994 PointsHi! I tried this question just now. This passes:
You would want to use val instead of var whenever possible. This will lead to more robust code. Use var only when you absolutely need to change the variable.