# How following expression evaluate in rails?

**URL:** <https://www.ruby-forum.com/t/how-following-expression-evaluate-in-rails/157504>\
**Category:** Rails\
**Created:** [January 12, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/how-following-expression-evaluate-in-rails/157504 "2009-01-12T12:50:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [January 12, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/how-following-expression-evaluate-in-rails/157504/1 "2009-01-12T12:50:47Z")

</div>

Hi,

i have a following code  
abc= Abc.find(aa\_ids, :order =\> ‘created\_at desc’)  
abc.delete\_if { |event|  
(event.group\_id && !group\_ids.include?(event.group\_id) &&  
!event.group.is\_public?) || !Abc::SHOW\_EVENTS.include?(event.event\_type)  
}

I need to know that how this expression is evaluate what is the  
precedence of operator and does short circuit expression evaluation  
happen here

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [January 12, 2009, 3:43pm UTC](https://www.ruby-forum.com/t/how-following-expression-evaluate-in-rails/157504/2 "2009-01-12T15:43:13Z")

</div>

Sunny B. wrote:

> I need to know that how this expression is evaluate what is the  
> precedence of operator and does short circuit expression evaluation  
> happen here

[http://phrogz.net/ProgrammingRuby/language.html#table\_18.4](http://phrogz.net/ProgrammingRuby/language.html#table_18.4)

It’s also good practice to use parenthesis to explicitly force the  
precedence that you want rather than relying completely on a language’s  
operator precedence. It will be easier for you or anyone else looking at  
the code later to know the intent of the code.
