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


Groups > comp.lang.ruby > #6559

Re: what's up with return *splat ?

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: what's up with return *splat ?
Date 2012-06-12 23:19 +0200
Message-ID <a3pq3mFm27U1@mid.individual.net> (permalink)
References <0fae13bb-3468-4883-b855-17950bee1117@t2g2000pbl.googlegroups.com>

Show all headers | View raw


On 12.06.2012 20:48, Phlip wrote:
> Rubies:
>
> Back in the Halcyon days (whatever that means) of Ruby 1.8, a function
> could obey the contract "return nil, a scalar, or an array" with a
> mere splat:
>
>    return * splat
>
> The interpretation there is (roughly!) "splat behaves as if you had
> written each argument in an array as scalars separated by commas."
>
> So (roughly!), you would get one of these three results:
>
>    return nil
>    return scalar
>    return [ scalar1, scalar2, scalar3 ]
>
> Now that I work in Ruby 1.9, the splat don't work like that. It just
> passes through an array.
>
> Am I using it wrong? Did splat change? If so, why? And can I use some
> other 1.9-compliant trick?

Can you please show the code you used for testing?  Thank you.

Kind regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

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


Thread

what's up with return *splat ? Phlip <phlip2005@gmail.com> - 2012-06-12 11:48 -0700
  Re: what's up with return *splat ? Robert Klemme <shortcutter@googlemail.com> - 2012-06-12 23:19 +0200
    Re: what's up with return *splat ? Phlip <phlip2005@gmail.com> - 2012-06-12 17:10 -0700
      Re: what's up with return *splat ? Robert Klemme <shortcutter@googlemail.com> - 2012-06-16 15:04 +0200
        Re: what's up with return *splat ? Phlip <phlip2005@gmail.com> - 2012-06-21 16:24 -0700
          Re: what's up with return *splat ? Robert Klemme <shortcutter@googlemail.com> - 2012-06-22 18:24 +0200
            Re: what's up with return *splat ? Phlip <phlip2005@gmail.com> - 2012-06-22 10:02 -0700
              Re: what's up with return *splat ? Robert Klemme <shortcutter@googlemail.com> - 2012-06-22 23:36 +0200
                Re: what's up with return *splat ? Phlip <phlip2005@gmail.com> - 2012-06-24 16:27 -0700

csiph-web