Hi,

Am Donnerstag, 24. Dez 2009, 08:32:29 +0900 schrieb Alfonso Caponi:
> meth(sth) do |a,b,c|
>  push a,b,c into array
> end
> 
> if array is not empty
>  printf("%10s %10s %10s\n",a,b,c)
> end

You maybe mean a situation in that the length of the argument list
can change: |a,b,c,...|. Then you could use splats. Here's an
example:

  def fade_away
    yield "a", "b", "c"
    yield "a", "b"
    yield "a"
    yield
  end

  fade_away do |*args|
    if args.any? then
      puts args.join
    else
      puts "."
    end
  end

You can use splats in many other contexts:

  def some_method *args
    a, b, c, * = *args
  end

  ary = [ /^y/, "ja", "oui", "si", "s]
  case answ
    when *ary then do_it
  end

Everything untested.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
*
Discover String#notempty? at <http://raa.ruby-lang.org/project/step>.