Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > naming parameters in the method calls

Reply
Thread Tools

naming parameters in the method calls

 
 
aidy
Guest
Posts: n/a
 
      09-13-2006
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

 
Reply With Quote
 
 
 
 
Farrel Lifson
Guest
Posts: n/a
 
      09-13-2006
On 13/09/06, aidy <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Javax.naming Exception: name not found in naming service. Harman Java 1 07-28-2006 08:51 AM
ods calls business object then method calls ta with output params andy6 ASP .Net 2 06-09-2006 01:54 AM
invoke a method by reflection£¨the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
Named parameters in method calls fishfry Perl Misc 3 02-09-2004 09:55 PM



Advertisments