# Can someone explain what is wrong with my syntax?

**URL:** <https://www.ruby-forum.com/t/can-someone-explain-what-is-wrong-with-my-syntax/155416>\
**Category:** Rails\
**Created:** [December 11, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/can-someone-explain-what-is-wrong-with-my-syntax/155416 "2008-12-11T17:00:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bushymark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@bushymark](https://www.ruby-forum.com/u/bushymark)\
**Post date:** [December 11, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/can-someone-explain-what-is-wrong-with-my-syntax/155416/1 "2008-12-11T17:00:29Z")

</div>

Hey Everyone, I think this should be an easy one, and the solution  
right now was to use two lines instead of one, but I am curious why  
this syntax isn’t working.

Assignment.find(:all).delete\_if {|assignment|  
assignment.assignment\_name == “Lunch” || assignment.assignment\_name ==  
“Lunch”}

This will return the array without the “Lunch”, but with the break  
still in tact, so I tried again:

Assignment.find(:all).delete\_if {|assignment|  
assignment.assignment\_name == (“Lunch” || “Break”)}

Nope! No good, once again, lunch is gone, but break is still in the  
array.

tried to do the same thing with select as well . . . no dice. I have  
this working right now with two lines of code, but I am really curious  
where my syntax is going wrong. More a question of interest then  
anything else.

Thanks!

---

<div class="post-metadata">

**Author:** ![bushymark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@bushymark](https://www.ruby-forum.com/u/bushymark)\
**Post date:** [December 11, 2008, 5:10pm UTC](https://www.ruby-forum.com/t/can-someone-explain-what-is-wrong-with-my-syntax/155416/2 "2008-12-11T17:10:30Z")

</div>

On 11 Dec 2008, at 15:59, BushyMark wrote:

> still in tact, so I tried again:
> 
> Assignment.find(:all).delete\_if {|assignment|  
> assignment.assignment\_name == (“Lunch” || “Break”)}
> 
> Nope! No good, once again, lunch is gone, but break is still in the  
> array.

That doesn’t do what you think it does. First it evaluates (“Lunch” ||  
“Break”) which evaluates to “Lunch”, so that just does

Assignment.find(:all).delete\_if {|assignment|  
assignment.assignment\_name == “Lunch”}

you would need

Assignment.find(:all).delete\_if do |assignment|  
assignment.assignment\_name == “Lunch” || assignment.assignment\_name  
== “Break”  
end

or

Assignment.find(:all).delete\_if do |assignment|  
[“Lunch”, “Break”].include? assignment.assignment\_name  
end

Fred
