I want to run a program which changes the background depending on which gender you choose in a edit list.
Shoes.app do
para "your gender"
list_box :items => ["female", "male"],
width => 120, :choose => "weiblich" do |list|
@gender.text = list.text
end
@gender = para "#{@gender}"
button "change colours" do
if @gender ="female"
background (deeppink)
else @gender ="male"
background (dodgerblue)
end
end
end
The problem is – whatever I do, if I use the if-statement, suddenly always “female” is in the variable and my background is pink, altough when I pick “male”. If I just do
...
button "change colours" do
para @gender
end
....
the right gender is in the variable @gender. Does anybody know what the problem is?
You need
if @gender == "female"andif @gender == "male"– note the two=symbols.You’re performing an assignment, not testing equality.