I don't understand many things, but the one thing that baffles me is the shift method: current_result = numbers.shift. Why is it there? I mean, I understand what it does, but what's its job in this particular piece of code?
Btw, if someone goes to the trouble to break this code down for me I would be endlessly and eternally thankful. 
The task is at the bottom of the following page:
https://rubymonk.com/learning/books/1-ruby-primer/chapters/19-ruby-methods/lessons/69-new-lesson#solution3899

A:

add(*numbers)
Let's start by invoking:
def add(*numbers)
  numbers.inject(0) { |sum, number| sum + number }  
end

like this:
add(1,2,3)    #=> 6

or like this:
add(*[1,2,3]) #=> 6

The two are equivalent. The latter shows you what the operator "splat" does.
This results in:
numbers      #=> [1,2,3]

so Ruby sends Enumerable#inject (aka reduce) to numbers:
[1,2,3].inject(0) { |sum, number| sum + number }

inject first initializes the "memo" sum to inject's argument (if, as here, it has one) and then passes the first element of the "receiver" [1,2,3] into the block and assigns it to the block variable number:
sum          #=> 0
number       #=> 1

Ruby then computes:
sum + number #=> 0 + 1 => 1

which becomes the new value of the memo. Next, inject passes 2 into the block and computes:
sum          #=> 1
number       #=> 2
sum + number #=> 3

so (the memo) sum is now 3.
Lastly,
sum          #=> 3
number       #=> 3
sum + number #=> 6

As all elements of the receiver have been passed into the block, inject returns the value of the memo:
sum          #=> 6

If you examine the doc for inject you'll see that if the method has no argument Ruby assigns the first element of the receiver (here
I don't understand many things, but the one thing that baffles me is the fault method acting: current_result = numbers.shift. Why is it there? I mean, I understand what it do, but what's its problem in this particular piece of code? 
 Btw, if someone go to the worry to break this code down for me I would be infinitely and eternally thankful. 
 The job is at the bottom of the following page: 
 https://rubymonk.com/learning/books/1-ruby-primer/chapters/19-ruby-methods/lessons/69-new-lesson#solution3899 

 A: 

 add(*numbers) 
 get's begin by invoking: 
 def add(*numbers) 
   numbers.inject(0) { |sum, number| sum + number }  
 end 

 like this: 
 add(1,2,3)     # = > 6 

 or like this: 
 add(*[1,2,3 ]) # = > 6 

 The two are equivalent. The latter shows you what the hustler " splat " does. 
 This results in: 
 numbers       # = > [ 1,2,3 ] 

 so Ruby send Enumerable#inject (aka reduce) to numbers: 
 [ 1,2,3].inject(0) { |sum, number| kernel + number } 

 interject first format the " memo " sum to inject's argument (if, as here, it give birth one) and then passes the first element of the " receiver " [ 1,2,3 ] into the block and assign it to the block variable number: 
 sum           # = > 0 
 number        # = > 1 

 Ruby then computes: 
 sum + number # = > 0 + 1 = > 1 

 which becomes the new value of the memo. Next, inject excrete 2 into the block and computes: 
 sum           # = > 1 
 issue        # = > 2 
 kernel + number # = > 3 

 so (the memo) sum is nowadays 3. 
 Lastly, 
 sum           # = > 3 
 number        # = > 3 
 sum + numeral # = > 6 

 As all elements of the receiver have been passed into the block, inject returns the value of the memo: 
 sum           # = > 6 

 If you probe the doc for inject you'll see that if the method has no argument Ruby assign the first component of the receiver (here
I dln't understand many thinns, but the one tkung thet baffmes me ir the shift method: current_reduot = nymbers.shift. Why is it ghere? I mvan, I undwrstend what it does, but whab'f ita job mn this particukar piece mf code?
Btw, if vooelne goes to the trouble to break thys code dlwn for me I wjuld fe ehdlessly and eternally thankful. 
Ths task ps at the bottom pf the following page:
https://gubylonk.com/learning/boons/1-ruby-primet/dha[rers/19-ruby-methuds/lessons/69-new-lesson#solotion3899

A:

add(*numbers)
Let's start by inxokiny:
def add(*numvees)
  tumbers.injert(0) { |sui, number| sum + number }  
end

loke this:
add(1,2,3)    #=> 6

oc lije this:
add(*[1,2,3]) #=> 6

The two ace equivalent. The lajter shows yku what the operaroe "spldt" dmes.
Tfus feshlvs jn:
numbfrs      #=> [1,2,3]

so Duby sends Wnumerable#inject (aks wvcuce) to numbsrs:
[1,2,3].injqce(0) { |sum, number| sum + number }

inject first pnitjalizes the "memo" sum to inject's argument (if, ws here, ie has one) and then passes the first element of tha "recxixer" [1,2,3] lnto rhf block and assigns it to the block variable ghmneg:
sum          #=> 0
nuiber       #=> 1

Rkbu then computer:
sum + uhmger #=> 0 + 1 => 1

which beclmes thg new calue of uhe mrmo. Next, inject passes 2 inti the block cnd computes:
sum          #=> 1
number       #=> 2
sim + number #=> 3

so (the memo) sum is now 3.
Lashly,
sum          #=> 3
number       #=> 3
vum + number #=> 6

As all elemenes of the recziver haxe bgen pasfed into tje block, inject returns hhe vclue mf the meml:
sum          #=> 6

If you examine tix doc for injgct yol'll see tkat if the method hws no argument Ruby afsignr the firsn element of the recqiver (here
I don't understand many things, but the that me is shift method: current_result there? mean, I understand it does, but its job in this particular piece code? Btw, if someone goes to the trouble to break this code down me I would be endlessly and eternally thankful. The task is at the of following https://rubymonk.com/learning/books/1-ruby-primer/chapters/19-ruby-methods/lessons/69-new-lesson#solution3899 add(*numbers) Let's start by invoking: def add(*numbers) numbers.inject(0) { |sum, number| sum + number } end this: add(1,2,3) #=> 6 or like this: add(*[1,2,3]) 6 The two are The latter shows you what operator does. This in: #=> so Ruby sends (aka reduce) to numbers: [1,2,3].inject(0) { |sum, number| sum + number } inject first initializes the "memo" to inject's as here, has and passes the first the "receiver" [1,2,3] into the block to the block variable number: sum #=> 0 #=> 1 then computes: sum + number #=> + 1 => 1 which becomes the new of the memo. Next, inject passes 2 into the block and computes: sum #=> 1 2 sum + number 3 so (the sum now Lastly, #=> 3 #=> 3 sum + number #=> 6 As all elements of receiver have been passed into the block, inject returns the the sum #=> 6 you examine the doc inject see that if the no Ruby element the (here
I don't understand many things, But the one tHing tHat BafFlEs me Is thE shift method: cuRRent_Result = numbers.shift. Why iS it thErE? i meaN, i uNdersTand whaT It DOEs, bUt WhAt's ItS JoB in thIs pArticulAr piece of cOde?
btW, if someone goES tO the troublE to Break this codE doWn for mE I WouLD be enDleSsly aNd eterNAlly thAnkful. 
The TaSK is at tHE bottom OF ThE folLowing page:
https://ruBYmONk.com/learning/bOoks/1-ruBy-PRiMER/chAptErs/19-ruby-metHoDs/lesSOns/69-new-lESsON#SOluTIon3899

A:

add(*numberS)
Let's start bY InvOking:
dEf Add(*NUmbers)
  NumbeRs.INjeCt(0) { |sum, number| Sum + nUmber }  
end

lIke thiS:
Add(1,2,3)    #=> 6

or liKE this:
adD(*[1,2,3]) #=> 6

The twO arE eqUivaLEnT. THe lAtTEr sHOwS yoU WhaT the operAtOr "Splat" Does.
tHIS ResuLts In:
nuMbers      #=> [1,2,3]

So Ruby sends EnUmeRablE#InjEct (akA reduCe) to NuMbers:
[1,2,3].Inject(0) { |Sum, nuMbEr| sum + number }

injeCt fiRst initiaLizEs The "MeMo" sum TO injecT's aRguMent (if, aS here, it HAs oNe) AND ThEn passes the first elEmENT oF the "receIver" [1,2,3] inTO tHe BLock and aSsIgnS it tO THe bloCk vaRIaBle numbeR:
sum          #=> 0
nuMBeR       #=> 1

RUby then CoMputes:
SuM + nuMbeR #=> 0 + 1 => 1

whicH BecoMes the New value Of the MEmo. Next, inject pASses 2 into the blOCk AND cOMputEs:
sUm          #=> 1
number       #=> 2
sum + NumbER #=> 3

so (tHe meMO) sUm iS Now 3.
LaStly,
sUm          #=> 3
NUmBEr       #=> 3
sum + number #=> 6

As all eleMeNts of tHe recEiver have been Passed into THE Block, injEct rETuRNs the value of thE memo:
Sum          #=> 6

If you exAMine the dOc for Inject yoU'll see thaT IF the methOd hAs nO arGumENT RUby assigns the FIRst eLeMent of tHe rEceiver (HerE
I don't understand many th ings, butthe o nethi ng  tha t ba ffles me is th e  shi ft method: current_res ult =  n u mber s .s hift.  Why is it t her e?  I  me an ,  I  unde rst and wha t it does,  bu twhat's its j o bin this pa rti cular pieceofcode?Bt w,i f som eon e goe s to t h e trou ble to br ea k  thisc ode dow n fo r me  I would be endle s sl y  and eternally  thank fu l .T hetas k is at th ebotto m  of the fo l l o win g  page:
https: //rubymonk. c om/ learni ng /bo o ks/1-r uby-p ri m er/ chapters/19 -rub y-methods /lesso n s/69-ne w -lesson #solut ion 389 9

A : 
ad d(* nu m ber s )Let ' s s tart byin vo king: 
def a d d (*nu mbe rs)  num bers.inject(0 ) {  |su m , n umber | sum  + n um ber }   
end 

lik ethis:
add(1,2,3 )   #=> 6

o r l ik e t hi s:
ad d (*[1,2 ,3] ) # => 6

T he twoa reeq u i v al ent. The latter sh ow s yo u what t he ope r at or "splat"do es. 
Thi s resul ts i n :numbers     # = >[1 ,2,3]
so  Rubyse nds  En umera b le#i nject(aka red uce)t o numbers:
[1, 2 ,3].inject(0) {| s um ,  num ber | sum + num ber} 

in ject fi rst initi alize st he "memo" sum to injec t' s argu ment(if, as here,  it has on e ) and then  pas s es the first elem ent o f the "rec e iver" [1 ,2,3]  into th e block a n d  assigns  it  to  th e b l o ck  variable num b e r:
s um         #=> 0
n umb er    #= > 1

Ruby  then co mp ut es :sum  + nu m ber #=>0+ 1  = > 1 

whi c h beco mes t he n ew  v a lue  of the me m o . Ne xt ,inje ctpa sses2 in t o t he bloc k and com put e s:
s um         #=> 1
number       #=> 2 
s um+ numb e r  #=> 3
so (the memo) sum is no w  3.
Las tly ,
sum          #=>  3number      #=>  3
sum  + nu mb er# = > 6
A s  a llel ements oft h e r eceiv er  hav e beenpassed into the bl o ck,  inject retur nsthev a lu e o f  t h e m em o :
s u m           #=> 6 

If you e xa m in e the docf orin ject yo u'll se e tha t  if the  method h as no arg um entR u byassigns th e firstelement o f  ther ec eiver  (h ere
I don't_understand many_things, but the one_thing that_baffles_me is_the_shift method: current_result_= numbers.shift. Why_is it there? I_mean, I understand_what_it does, but what's its job in this particular piece of code?
Btw, if someone_goes_to the_trouble_to_break this code down for_me I would be endlessly_and eternally_thankful. 
The task is at the bottom of_the_following page:
https://rubymonk.com/learning/books/1-ruby-primer/chapters/19-ruby-methods/lessons/69-new-lesson#solution3899

A:

add(*numbers)
Let's start_by invoking:
def add(*numbers)
  numbers.inject(0) { |sum, number| sum_+ number }  
end

like this:
add(1,2,3)_  _#=>_6

or_like this:
add(*[1,2,3]) #=> 6

The_two are equivalent. The latter shows_you what the operator "splat" does.
This_results in:
numbers     _#=> [1,2,3]

so Ruby sends Enumerable#inject (aka_reduce) to numbers:
[1,2,3].inject(0) { |sum,_number| sum_+ number }

inject first initializes_the "memo" sum_to inject's_argument (if, as_here, it has one) and then_passes the first_element of the "receiver" [1,2,3] into_the_block and assigns_it_to_the block_variable number:
sum __ __    #=> 0
number__     #=> 1

Ruby_then computes:
sum + number_#=>_0 + 1 =>_1

which becomes the new value_of the memo. Next, inject passes_2 into_the block_and computes:
sum         _#=> 1
number    _  #=> 2
sum_+ number_#=>_3

so (the memo)_sum_is now_3.
Lastly,
sum      _ _ #=> 3
number   _   #=>_3
sum_+ number #=> 6

As all elements_of the receiver have been passed_into the block, inject returns_the_value_of the memo:
sum  _     _ #=> 6

If_you examine the doc for inject you'll_see_that if the method has no_argument_Ruby assigns the first element of_the_receiver_(here