Uso de SPLAT

24 views
Skip to first unread message

Pablo Joaquim

unread,
Dec 17, 2013, 2:24:02 PM12/17/13
to rubyonra...@googlegroups.com
Ola, sou novo com ruby e estou tentando aprender mais sobre ele, porem me deparei com um fato estranho.
De acordo com o código a baixo eu vou ter duas saídas, porem não entendo o por que de ter valores diferentes quando uso a syntax sugar em conjunto com splat.
Alguém pode me responder isso?

class teste
  
  def faz=(*lista)
     puts lista.size
  end
 
  def fast(*lista)
     puts lista.size
  end

end

var = teste.new
var.faz="a", "b", "c"
=>1

var.fast"a", "b", "c"
=>3

Marco Antonio Almeida

unread,
Dec 17, 2013, 5:58:03 PM12/17/13
to rubyonra...@googlegroups.com
Hi Pablo,

This is an international list, so if you want your answer you should write your question in English.

For this one I will answer your question in private.

Marco Antonio Almeida
+45 31 65 28 84
Twitter: @marcoafilho | LinkedIn: marco-antonio-almeida-filho


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3939c4ae-c2aa-4387-8fe2-52044a538835%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages