Showing posts with label CSFPRTMMSLUATCASL. Show all posts
Showing posts with label CSFPRTMMSLUATCASL. Show all posts

Code Samples From "Programming Ruby" That Made Me Stop, Look Up At the Ceiling, and Sigh Longingly (Part 2)

CHAPTER 4. CONTAINERS, BLOCKS, AND ITERATORS

PAGE 49

def with_title(title)

  @songs.find {|song| title == song.name }

end

Code Samples From "Programming Ruby" That Made Me Stop, Look Up At the Ceiling, and Sigh Longingly (Part 1)

CHAPTER 4. CONTAINERS, BLOCKS, AND ITERATORS

PAGE 44

a = [ 1, 3, 5, 7, 9]

a[-1]    ->  9

a[-2]    ->  7

a[-99]   ->  nil