开发者

Ruby Shoes - Problem with edit list and if-statement

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 v开发者_JS百科ariable @gender. Does anybody know what the problem is?


You need if @gender == "female" and if @gender == "male" - note the two = symbols.

You're performing an assignment, not testing equality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜