Explanation
“@instance:” allows us to attach an object/value to the Foo class instead of Foo’s prototype. Recall that “@” in CoffeeScript refers to JavaScript’s “this”.
After “@instance:” there is a function that is immediately executed. This function returns a function, closed around a variable called instance. Both these functions have their context (their “this”) bound to the Foo object using CoffeeScript’s wonderful “define and bind” operator “=>” as opposed to the normal function definition operator “->”.
When called, the function that “@instance” ends up referring to simply checks to see if the “instance” variable is empty and if so, assigns a new instance of Foo to it. Newing up a Foo is done using the “@” symbol since the function’s “this” refers to the Foo object. It then returns the instance.
Output
The CoffeeScript above compiles down to this:
Hi! Someone in my Myspace group shared this website with us so I came to give it a look.
I’m definitely loving the information. I’m bookmarking and will
be tweeting this to my followers! Outstanding blog and fantastic design and style.
Thank you for sharing your thoughts. I really appreciate your efforts
and I will be waiting for your next post thanks once again.
Every weekend i used to visit this site, as i wish
for enjoyment, as this this site conations really nice funny data too.
Hey there! I’ve been reading your web site for a
while now and finally got the bravery to go ahead and give you
a shout out from New Caney Texas! Just wanted to say keep up the fantastic
work!
Thankfulness to my father who informed me about this web site, this webpage is really amazing.
I have been browsing on-line greater than three hours nowadays, but
I by no means discovered any interesting article like yours.
It is lovely price enough for me. Personally, if all website owners and bloggers made just right content
as you probably did, the internet might be a lot more helpful than ever before.
I am actually delighted to read this blog posts
which contains plenty of helpful facts, thanks for providing these data.
Wow, wonderful blog format! How long have you been running a blog for?
you make blogging look easy. The overall look of your web site is excellent, as smartly as the content material!
Wow, amazing blog layout! How lengthy have you
been blogging for? you made blogging look easy. The full glance of
your website is great, as well as the content!
Hello everyone, it’s my first pay a quick visit at this site,
and piece of writing is truly fruitful in support of me, keep up posting such content.
I know this site presents quality based posts and extra information, is there
any other web page which gives these data in quality?
Thanks for the marvelous posting! I certainly enjoyed
reading it, you are a great author. I will always bookmark your blog and will often come back down the
road. I want to encourage you to ultimately continue your
great work, have a nice morning!