Ask a Question related to Ruby, Design and Development.
-
Kent Dahl #1
Re: "Apply" method to array?
Thomas Link wrote:
Like this?>
> Hi,
>
> This is a newbie question:
>
> Is there a way to apply (as in Lisp, Scheme and the like) a method/block
> to an array, so that the elements of the array become the arguments of
> the method call. Something like:
>
> a(1,2,3) ~~ a.apply([1,2,3])
a(*[1,2,3])
* is used in argument list to unpack array contents to arguments (like
here) or to pack arguments into an array,like in "def mymethod(*args)"
--
(\[ Kent Dahl ]/)_ _~_ _____[ [url]http://www.pvv.org/~kentda/[/url] ]_____/~
))\_student_/(( \__d L b__/ (pre-) Master of Science in Technology )
( \__\_õ|õ_/__/ ) _)Industrial economics and technological management(
\____/_ö_\____/ (____engineering.discipline_=_Computer::Technology ___)
Kent Dahl Guest
-
Can't locate object method "newFromJpeg" via package "GD::Image"
Hi. I'm trying to execute this Perl simple script: -------- #!/usr/bin/perl use GD; my $srcimage = GD::Image->newFromJpeg("image_news.jpg");... -
Can't locate object method "blocking" via package "IO::Handle"
I am receiving the error message: Can't locate object method "blocking" via package "IO::Handle" at... -
Can't locate object method "new" via package "Net::SMTP"
I'm attempting to use the line: $smtp = Net::SMTP->new("mailhost.myisp.co.uk"); however it generates the error message: Can't locate object... -
Can't locate object method "get" via package "LWP::UserAgent"
#!/usr/bin/perl use strict; use URI; #use HTTP::Request::Common qw(GET); use LWP; #use HTTP::Response; my $browser = LWP::UserAgent->new;... -
Can't not locate object method "isadmin" via package "Noc1"
Hello all, I just added a new method called isadmin to existing and working module Noc1.pm And use this new added method in my index.html... -
Thomas Link #2
Re: "Apply" method to array?
> Like this?
Excellent. Thanks a lot.> a(*[1,2,3])
>
> * is used in argument list to unpack array contents to arguments (like
> here) or to pack arguments into an array,like in "def mymethod(*args)"
Ciao,
Thomas.
Thomas Link Guest
-
Unregistered #3
Re: "Apply" method to array?
but what if i need e.g. to multiply all the array elements? you can't use * as a method.
Unregistered Guest
-



Reply With Quote


