Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #5042

Re: Generating Functions in Ruby

From 7stud -- <bbxx789_05ss@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: Generating Functions in Ruby
Date 2011-05-25 12:26 -0500
Organization Service de news de lacave.net
Message-ID <fdbf43fe23ee24877a4ce4b4a579258b@ruby-forum.com> (permalink)
References (1 earlier) <dc2df7d480159878c42c65807d568cd8@ruby-forum.com> <151562ef-aebd-4999-8b7b-816c21a7c6df@m40g2000vbt.googlegroups.com> <917a6bebd84192c90d0434fe9ec9e2a4@ruby-forum.com> <a7767bf3bf24b12dca32299294f73970@ruby-forum.com> <ed726629-f977-4281-81b6-776e22f4e580@y31g2000vbp.googlegroups.com>

Show all headers | View raw


Andreas Lundgren wrote in post #1000859:
>> --output:--
>> "x1.to_s, x2.to_s, x3.to_s, x4.to_s"
>>
>> Also, compare that output to the output your loop produces:
>>
>>  "x1.to_s + ', ' + x2.to_s + ', ' + x3.to_s + ', ' + x4.to_s"
>>
>> You would get many errors using that string as an argument list for a
>> method.
>
> I need this since parameters to win32ole are sent as a string with a
> comma separated list of arguments. That is to send in x1=1, x2='A' and
> x3=1.5 I do the call:
> handle.call(['MethodNameIn','Params'],['x1, x2, x3', '1, A, 1.5']);
>

If you need to send the string 'x1, x2, x3', then you need to create 
that string, not this garbage:

"x1.to_s + ', ' + x2.to_s + ', ' + x3.to_s + ', ' + x4.to_s"


Do you not see the difference between these two strings:

"x1, x2, x3"
"x1.to_s + ', ' + x2.to_s + ', ' + x3.to_s + ', ' + x4.to_s"


Do you not see that those strings have different lengths?  You seem to 
think that ruby is going to do some type of eval on the second string 
and you will end up with the first string, but ruby is not going to do 
that.  The second string above is a *string*, it is not an *expression*.

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

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-18 06:44 -0700
  Re: Generating Functions in Ruby Steve Klabnik <steve@steveklabnik.com> - 2011-05-18 09:34 -0500
  Re: Generating Functions in Ruby Robert Klemme <shortcutter@googlemail.com> - 2011-05-18 09:54 -0500
    Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-18 14:44 -0500
    Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-18 20:55 -0500
      Re: Generating Functions in Ruby Robert Klemme <shortcutter@googlemail.com> - 2011-05-19 08:31 +0200
        Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-19 13:00 -0500
          Re: Generating Functions in Ruby Robert Klemme <shortcutter@googlemail.com> - 2011-05-20 01:28 -0500
            Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-23 05:54 -0700
              Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-23 16:25 -0500
  Re: Generating Functions in Ruby Thomas Preymesser <thopre@gmail.com> - 2011-05-19 04:35 -0500
  Re: Generating Functions in Ruby Brian Candler <b.candler@pobox.com> - 2011-05-19 10:06 -0500
  Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-23 16:09 -0500
  Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-23 20:51 -0500
  Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-23 21:07 -0500
    Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-24 00:10 -0700
      Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-24 00:24 -0700
        Re: Generating Functions in Ruby Brian Candler <b.candler@pobox.com> - 2011-05-24 03:12 -0500
        Re: Generating Functions in Ruby Robert Klemme <shortcutter@googlemail.com> - 2011-05-24 03:39 -0500
          Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-24 06:46 -0700
            Re: Generating Functions in Ruby Robert Klemme <shortcutter@googlemail.com> - 2011-05-24 10:20 -0500
      Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-24 17:27 -0500
        Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-24 17:53 -0500
          Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-25 03:59 -0700
            Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-25 12:26 -0500
            Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-25 17:12 -0500
              Re: Generating Functions in Ruby Andreas Lundgren <andreas.lundgren.x@gmail.com> - 2011-05-27 04:48 -0700
  Re: Generating Functions in Ruby 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-24 16:54 -0500

csiph-web