What does << mean in Ruby?

前端 未结 8 628
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 12:13

I have code:

  def make_all_thumbs(source)
    sizes = [\'1000\',\'1100\',\'1200\',\'800\',\'600\']
    threads = []
    sizes.each do |s|
      threads <         


        
相关标签:
8条回答
  • 2020-12-04 12:38

    Also, since Ruby 2.6, the << method is defined also on Proc.

    Proc#<< allows to compose two or more procs.

    0 讨论(0)
  • 2020-12-04 12:42

    Mostly used in arrays to append the value to the end of the array.

    a = ["orange"]
    a << "apple"
    puts a
    

    gives this

      ["orange", "apple"] 
    result.

    0 讨论(0)
提交回复
热议问题