How can this Java method header be represented in Ruby

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.

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

Peter H. wrote:

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.

Peter H. wrote:

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

@Peter. Ruby is a dynamic language, sure it is :slight_smile:

Brian C. wrote:

Peter H. wrote:

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

Thanks @Brian. A nice one!

On Mon, Sep 20, 2010 at 2:42 AM, Brian C. [email protected]
wrote:

def file=(filename)

end

However, the ‘static’ in

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

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

def self.file=(filename)
end

FWIW,

Thanks all for your replies.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs