Skip to content

Instantiating multiple Cows with a specific cowfile #3

@thibaultcha

Description

@thibaultcha

Hi,

If you run this program:

Cow.new({ :cow => "vader" }).say("Hi")   #prints vader
Cow.new({ :cow => "default" }).say("Hi") #prints default
Cow.new({ :cow => "vader" }).say("Hi")   #prints default
Cow.new({ :cow => "koala" }).say("Hi")   #prints koala
Cow.new({ :cow => "default" }).say("Hi") #prints koala

You will notice that the output is wrong. Instantiating a Cow with a template for the first time is fine. But instantiating a Cow using another template, and then back to the first template, it doesn't work.

I am a very beginner in Ruby but I think this has to do with the class_eval you are doing in initialize.

I noticed this by building a small program that randomly selects a cow type at some point.

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