# Trouble with or

**URL:** <https://www.ruby-forum.com/t/trouble-with-or/92025>\
**Category:** Ruby\
**Created:** [April 14, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/trouble-with-or/92025 "2007-04-14T19:16:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [April 14, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/trouble-with-or/92025/1 "2007-04-14T19:16:43Z")

</div>

hello there,  
i am having a problem with a simple thing.

i have this ( trying to divide up a list into three more or less equal  
columns )  
i += 1  
if i == @sites.length / 3.to\_i  
or i == (@sites.length / 3).to\_i \* 2

i am getting a lot of unexpected kOR exceptions.

what am i doing wrong ?

thanks

sk

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [April 14, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/trouble-with-or/92025/2 "2007-04-14T19:22:43Z")

</div>

shawn bright wrote:

> i += 1  
> if i == @sites.length / 3.to\_i or  
> i == (@sites.length / 3).to\_i \* 2

Try this.

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Rule of Open-Source Programming #48:

The number of items on a project’s to-do list always grows or remains  
constant.

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [April 14, 2007, 8:29pm UTC](https://www.ruby-forum.com/t/trouble-with-or/92025/3 "2007-04-14T20:29:47Z")

</div>

oh, ok, i get it, thanks much gents!  
sk

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [April 14, 2007, 7:25pm UTC](https://www.ruby-forum.com/t/trouble-with-or/92025/4 "2007-04-14T19:25:43Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

shawn bright wrote:

> what am i doing wrong ?
> 
> thanks
> 
> sk

Your problem is that “if i == @sites.length / 3.to\_i” is a complete  
idea, so ruby doesn’t know the line is supposed to continue. You can  
either add a backslash at the end of the first line, or bring “or” up a  
line:

if i == @sites.length / 3.to\_i or  
i == (@sites.length / 3).to\_i \* 2

Dan Z.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFGIRwLUYnvW+YuEvYRAqUqAKCReYaovyyDqV+IyvTNtAnvS87rjACeJafM  
q7lpVZrz5kZU9CrEvI3zgug=  
=bVKA  
-----END PGP SIGNATURE-----
