Skip to content

arguments are not memoized #1

@zwily

Description

@zwily

Your documentation says that they are, but arguments are not memoized:

The script:

class Foo
  def bar(a)
    return a
  end
  memoize :bar
end

f = Foo.new
puts f.bar(1)
puts f.bar(2)

Outputs:

1
1

You need to keep a hash ivar that takes the array of args as a key, and calculated results as values.

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