New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton Pattern example error #104

Closed
daign opened this Issue Oct 23, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@daign

daign commented Oct 23, 2013

console.log( badSingleA.getRandomNumber() !== badSingleB.getRandomNumber() ); // true

I know what's meant to be illustrated in this example but actually you can't be sure two random numbers are unequal.

@addyosmani

This comment has been minimized.

Show comment
Hide comment
@addyosmani

addyosmani Dec 28, 2013

Owner

The idea being demonstrated here is that you're storing a specific value seeded by the random number generator which you're later comparing. You are however correct that there's a statistical chance the two numbers may be the same. I'll add a note to the book so that this is more clear. Thanks!

Owner

addyosmani commented Dec 28, 2013

The idea being demonstrated here is that you're storing a specific value seeded by the random number generator which you're later comparing. You are however correct that there's a statistical chance the two numbers may be the same. I'll add a note to the book so that this is more clear. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment