operators in ruby

M

Martin Durai

How to use logical operators in ruby?

Logical AND, OR, NOT..

In other languages like java &&, ||, ! is used. how we have to use it in
ruby.

A sample code in java, please explain it in ruby.

if((namespace == attributeUri[ i ] ||
namespace.equals(attributeUri[ i ]) )
&& name.equals(attributeName[ i ]) )

Please do the same in ruby

Thanks in advance
 
T

TerryP

Martin said:
How to use logical operators in ruby?

Logical AND, OR, NOT..

In other languages like java &&, ||, ! is used. how we have to use it in
ruby.

A sample code in java, please explain it in ruby.

if((namespace == attributeUri[ i ] ||
namespace.equals(attributeUri[ i ]) )
&& name.equals(attributeName[ i ]) )

Please do the same in ruby

Thanks in advance

It's just a matter of preference, use english or C-style symbols. The C-Stye
has precedence over the keyword versions (e.g. || rather then 'or' ).

Operators and Precedence (Top to bottom)
:: .
[]
**
-(unary) +(unary) ! ~
* / %
+ -
<< >>
&
| ^<=> == === != =~ !~
&&
||
... ...
=(+=, -=...)
not
and or

All of the above are just methods except these:
=, ::, ., .., ..., !, not, &&, and, ||, or, !=, !~

In addition, assignment operators(+= etc.) are not user-definable.
 
Y

yermej

How to use logical operators in ruby?

Logical AND, OR, NOT..

In other languages like java &&, ||, ! is used. how we have to use it in
ruby.

A sample code in java, please explain it in ruby.

if((namespace == attributeUri[ i ] ||
namespace.equals(attributeUri[ i ]) )
&& name.equals(attributeName[ i ]) )

Please do the same in ruby

Thanks in advance

http://whytheluckystiff.net/ruby/pickaxe/
 
P

Phrogz

How to use logical operators in ruby?

Logical AND, OR, NOT..

In other languages like java &&, ||, ! is used. how we have to use it in
ruby.

A sample code in java, please explain it in ruby.

if((namespace == attributeUri[ i ] ||
namespace.equals(attributeUri[ i ]) )
&& name.equals(attributeName[ i ]) )

Please do the same in ruby

Martin, please read a primer on Ruby and Java before posting all your
questions asking people to do each piece of your work for you. It
seems that you have a project or job to convert something from Java to
Ruby, but you don't seem to know either.

Learn the languages - even the basics - and you'll be able to do this
better on your own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,353
Members
48,038
Latest member
HunterDela

Latest Threads

Top