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

Mark Cranston
1,817 PointsCannot assign immutable value to type 'Bool'
I want to run a function when a variable is true, I get the error "Cannot assign immutable value to type 'Bool'", why is this happening and what can I do to fix it?
var variable = true
while variable = true{
function()
}
1 Answer

Steve Hunter
57,712 PointsThe single equals sign assigns a value to a variable. So, dayOfWeek = "Sunday"
or singaporeGPWinner = "Vettel"
etc.
To compare two things you can use the double-equals - ==
- that checks for equality rather than making one thing equal the other.
Your question lacks a language so I can't give you an example, but I hope this points you in the right direction. Please shout if I can help some more.
Steve.