A subscription is required to view this video. Enroll Today

Ruby

Core Ruby Classes

  • jaymcgavren
  • 2905 views

Jay McGavren gives an overview of a few Ruby Core Classes, covering examples from the String, Array, Hash, and Enumerable classes. If the Ruby language still feels new for you, this is definitely worth watching.

Comments

Faculty

Jay McGavren said

@mikestok right you are - the += is a little misleading. This would probably have been a better example:

sum = scores.inject(0) {|sum, value| sum + value}

Good catch!

Mike Stok said

In the explanation of inject using bowling scores in a season it seems redundant to use sum += value at the end of the inject block as the inject will put the return value of the block into the "accumulator", so

sum = scores.inject(0) do |accumulator, score| accumulator + score end

works and might give more insight into how inject works.

Download

Share