Cenoc
Cenoc

Reputation: 11672

Sinatra/Ruby Scope Issue

I was wondering, why is H in global scope in https://github.com/antirez/lamernews/blob/master/app.rb? You can see it defined on line 53, used on line 77, and out on line 127 in https://github.com/antirez/lamernews/blob/master/page.rb.

Any sage advice would be very much appreciated!

Upvotes: 1

Views: 44

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

Because constants, named with a leading capital letter, are accessible anywhere in the class or module in which they're defined, and outside using the leading ::.

Upvotes: 1

Related Questions