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.

···

--
Posted via http://www.ruby-forum.com/.

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 Hickman 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.

···

--
Posted via http://www.ruby-forum.com/\.

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

···

--
Posted via http://www.ruby-forum.com/.

Peter Hickman 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

···

--
Posted via http://www.ruby-forum.com/\.

Brian Candler wrote:

Peter Hickman 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!

···

--
Posted via http://www.ruby-forum.com/\.

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,

···

On Mon, Sep 20, 2010 at 2:42 AM, Brian Candler <b.candler@pobox.com> wrote:

def file=(filename)
...
end

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

Thanks all for your replies.

···

--
Posted via http://www.ruby-forum.com/.