Share and @ for global variable in coffee script difference?


#1

I am using coffeescript. When declaring a global variable you have to used @ or share. What is the difference? You still have to put share or @ every global variable if you want to access it.


#2

What is this “share”?
share a outputs share(a) in coffeescript.org


#3

Looks like there’s an explanation here https://github.com/foxdog-studios/meteor-coffeescript-share, though I’ve not used this technique before.


#4

@JamesLefrere yes. that’s my point. you have to put share keyword every global variable. In the link you post this is the example given

1_first.coffee
   share.greet = (name) ->
     console.log "Hello, #{ name }!"

2_second.coffee
   share.greet 'World'

Why bother used share. When you can just used @ sign? like this one

1_first.coffee
   @greet = (name) ->
     console.log "Hello, #{ name }!"

2_second.coffee
   @greet 'World'

#5

@manuel share keyword for global variable in coffeescript