Skip to content

There are mentions of 'methods' but no actual example of one. #3

Open
@GBH

Description

@GBH

I think it would be a great idea to explain exactly what a method is right after introducing Objects.
99.next looks like magic. But if you show that it's actually a method that can look like this:

class Integer
  def next
    self + 1
  end
end

... it removes some of the mystery. Plus there are opportunities to use methods in later examples, like n bottles of beer on the wall. Why start with 99? Pass whatever you want into a method. Even better, recursive method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions