How can this Java method header be represented in Ruby

A

Abder-Rahman Ali

I have a Java method header that looks something like follows:

public static short[][] setFile(String fileName)
{
...
}

How can I write this in Ruby?

Thanks.
 
P

Peter Hickman

def setFile(fileName)
...
end

You do realise that Ruby is a dynamic language, there is no typing?

How you name your methods and variables is up to you but I would go with

def set_file(filename)
...
end
 
A

Abder-Rahman Ali

Peter said:
def setFile(fileName)
...
end

You do realise that Ruby is a dynamic language, there is no typing?

How you name your methods and variables is up to you but I would go with

def set_file(filename)
...
end

Thanks @Peter. And, of course, the second form is more suitable
especially for Ruby convention.
 
B

Brian Candler

Peter said:
How you name your methods and variables is up to you but I would go with

def set_file(filename)
...
end

Or even:

def file=(filename)
...
end
 
H

Hassan Schroeder

=A0def file=3D(filename)
=A0 =A0...
=A0end

However, the 'static' in

public static short[][] setFile(String fileName)

means it's a class, not instance, method so

def self.file=3D(filename)
end

FWIW,
--=20
Hassan Schroeder ------------------------ (e-mail address removed)
twitter: @hassan
 

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,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top