Ruby equivalent of Integer.toHexstring(int) method in java

A

anil kandimalla

Hi all
Hi guys i am new to ruby,i am searching for a ruby method which
gives the same output as given by Integer.toHexstring(int),but unable
to find any methods.

Is there is a ruby method or can i call this java method from a ruby
file and passing the parameter and get the output from this java
method.

Any help is greatly appreciated.

Thanks
 
R

Robert Klemme

2008/9/10 anil kandimalla said:
Hi guys i am new to ruby,i am searching for a ruby method which
gives the same output as given by Integer.toHexstring(int),but unable
to find any methods.

Is there is a ruby method or can i call this java method from a ruby
file and passing the parameter and get the output from this java
method.

irb(main):001:0> 123.to_s 16
=> "7b"
irb(main):003:0> "%x" % 123
=> "7b"
irb(main):004:0> sprintf "%x", 123
=> "7b"
irb(main):005:0> printf "%x\n", 123
7b
=> nil

Cheers

robert
 
L

Lex Williams

anil said:
Hi all
Hi guys i am new to ruby,i am searching for a ruby method which
gives the same output as given by Integer.toHexstring(int),but unable
to find any methods.

Is there is a ruby method or can i call this java method from a ruby
file and passing the parameter and get the output from this java
method.

Any help is greatly appreciated.

Thanks

if you don't like the ruby way , you could call that method directly
from jruby :)
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top