Forum: Ruby trouble with or

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-04-14 19:16
(Received via mailing list)
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
Ac0085dae0703db56ad7f8cb9e1798ba?d=identicon&s=25 Phillip Gawlowski (Guest)
on 2007-04-14 19:22
(Received via mailing list)
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://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.
Caf38c89d40443a858741b61ac6d82de?d=identicon&s=25 Dan Zwell (Guest)
on 2007-04-14 19:25
(Received via mailing list)
-----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 Zwell
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGIRwLUYnvW+YuEvYRAqUqAKCReYaovyyDqV+IyvTNtAnvS87rjACeJafM
q7lpVZrz5kZU9CrEvI3zgug=
=bVKA
-----END PGP SIGNATURE-----
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-04-14 20:29
(Received via mailing list)
oh, ok, i get it, thanks much gents!
sk
This topic is locked and can not be replied to.