Enum_inject mail protected]@J8

e$B;38}$H?=$7$^$9!#e(B

e$B%j%j!<%9D>A0$N$K;$7$$;~4|$KBgJQ:Y$+$$OC$G62=L$J$N$G$9$,!"e(Benum.c
e$B$Ne(B enum_inject e$B$K$
[email protected]@J8$K8m$j$,$"$k$h$&$G$9!#e(B

[1,2,3].inject(0, :+)
#=> 6

[1,2,3].inject(:+, 0)

=> in `inject: 0 is not a symbol (TypeError)

from -e:1:in `

Index: enum.c

enum.c (e$B%j%S%8%g%se(B 14517)
+++ enum.c (e$B:n6H%3%T!<e(B)
@@ -370,12 +370,12 @@

/*

  • call-seq:
    • enum.inject(sym, initial) => obj
      
    • enum.inject(initial, sym) => obj
      
    • enum.inject(sym)          => obj
      
    • enum.inject(initial) {| memo, obj | block }  => obj
      
    • enum.inject          {| memo, obj | block }  => obj
      
    • enum.reduce(sym, initial) => obj
      
    • enum.reduce(initial, sym) => obj
      
    • enum.reduce(sym)          => obj
      
    • enum.reduce(initial) {| memo, obj | block }  => obj
      
    • enum.reduce          {| memo, obj | block }  => obj
      

@@ -403,7 +403,7 @@

  • # Same using a block and inject
    
  • (5..10).inject {|sum, n| sum + n }            #=> 45
    
  • # Multiply some numbers
    
    • (5..10).reduce(:*, 1)                         #=> 151200
      
    • (5..10).reduce(1, :*)                         #=> 151200
      
    • # Same using a block
      
    • (5..10).inject(1) {|product, n| product * n } #=> 151200
      
    • # find the longest word
      

e$B;38}[email protected](B
e$BKL3$F;Bg3XBg3X1!J83X8&5f2Je(BD3
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs