Ian Amuhton
1/7/2006 2:29:00 AM
ssmoot@gmail.com wrote:
> "*names.map" should be "names.map".
Ah, my error in copying.
> The * before a variable name in a method definition is
> basically equiv to the "params" keyword in Microsoft
> languages if that helps.
That much I knew. But why do you have to do all this (using your
version):
system("ri #{names.map { |name| name.to_s }.join(' ')}")
instead of just
system("ri #{names}.to_s"}
?
> %{} is basically short-form for a HEREDOC.
Ah, thanks.
> I don't like it personally.
> A slightly cleaner example (that works) might look like this:
>
> def ri(*names)
> system("ri #{names.map { |name| name.to_s }.join(' ')}")
> end
Both your version, and the original one modified with the * removed from
"names" still cause Cygwin to dump core in irb:
--------------------------------------------------------------
>> ri Proc
C:\cygwin\bin\ruby.exe (3132): *** unable to remap
C:\cygwin\lib\ruby\1.8\i386-cygwin\readline.so to same address as
parent(0x370000) != 0x2760000
C:\cygwin\bin\ruby.exe (3132): *** unable to remap
C:\cygwin\lib\ruby\1.8\i386-cygwin\readline.so to same address as
parent(0x370000) != 0x2760000
19 [main] 2888 fork_parent: child 3132 died waiting for dll
loading /home/Jelks/.irbrc:4: [BUG] rb_sys_fail() - errno == 0
ruby 1.8.3 (2005-09-21) [i386-cygwin]
Aborted (core dumped)
[blackie] ~
$
--------------------------------------------------------------
I get the same error, though without the core dump if I do it as a Ruby
program.
Under plain Windows, your version above returns "false", while the
modified original still returns:
'name' is not recognized as an internal or external command,
operable program or batch file.
=> false
Perhaps I should go fire up a Linux box. If I can get it working there,
then it must be a Ruby under Cygwin and a Ruby under Windows issues.
--
da
~~