# If else statement problem

**URL:** <https://discuss.rubyonrails.org/t/if-else-statement-problem/19687>\
**Category:** rubyonrails-talk\
**Created:** [October 25, 2007, 11:43am UTC](https://discuss.rubyonrails.org/t/if-else-statement-problem/19687 "2007-10-25T11:43:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edd\_Morgan](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@Edd\_Morgan](https://discuss.rubyonrails.org/u/Edd_Morgan)\
**Post date:** [October 25, 2007, 11:43am UTC](https://discuss.rubyonrails.org/t/if-else-statement-problem/19687/1 "2007-10-25T11:43:50Z")

</div>

On first glance, it looks like your 'else' block won't ever run unless there is some definition of @logos above that code that you had forgotten to paste. This may be why the second rotation doesn't ever happen (if that is your problem).

Forgive me if I'm misinterpreting you.

- Edd [http://www.eddm.co.uk](http://www.eddm.co.uk)

---

<div class="post-metadata">

**Author:** ![David\_A\_Black](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@David\_A\_Black](https://discuss.rubyonrails.org/u/David_A_Black)\
**Post date:** [October 25, 2007, 12:10pm UTC](https://discuss.rubyonrails.org/t/if-else-statement-problem/19687/2 "2007-10-25T12:10:48Z")

</div>

Hi --

---

<div class="post-metadata">

**Author:** ![Edd\_Morgan](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@Edd\_Morgan](https://discuss.rubyonrails.org/u/Edd_Morgan)\
**Post date:** [October 25, 2007, 1:06pm UTC](https://discuss.rubyonrails.org/t/if-else-statement-problem/19687/3 "2007-10-25T13:06:34Z")

</div>

That is correct, and syntactically I see nothing wrong with your code. However, from what I can see the if statement will always evaluate to true because @logos will always be null.

- Edd

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [October 25, 2007, 3:34pm UTC](https://discuss.rubyonrails.org/t/if-else-statement-problem/19687/4 "2007-10-25T15:34:26Z")

</div>

Only if it's the same object, since @logos is just an instance variable. If for example this was in a controller then the second time you hit the web page you'll get a new instance of the controller and so @logos will be nil again.

Fred
