Farrel Lifson
9/13/2006 10:09:00 AM
On 13/09/06, aidy <aidy.rutter@gmail.com> wrote:
> Hi,
>
> In BASIC, it is possible to name the parameters in the method calls
>
>
> call:
>
> test_info(test_description := "Check that window displayed is correct",
>
> expected_result := "Correct image is displayed")
>
>
>
> method
>
> sub test_info (test_description, expected_result)
>
> Is it possible to do the same in Ruby?
>
> Thanks for your help
>
> aidy
>
>
>
I do believe this might be a new feature in Ruby 2.0? I'm not sure if
it's confirmed though.
In the meantime you can kind of fake it using hashes. Ruby is clever
enough to know when to convert an argument list to a hash like so:
def talk(params)
puts "Hello, I am #{params[:name]} and I am #{params[:age]} years old"
end
talk(:name=>"Bob",:age=>27)
Farrel