Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Query on Module

I am new to Ruby and was going through some tutorials, where I come with the following code

module DecimalCode RED = "rgb(255,0,0)" GREEN = "rgb(0,128,0)"

def code return "RED : Decimal code #{RED}" end

def DecimalCode.code return "GREEN : Decimal code #{GREEN}" end

def hello return "Hello world!" end

end

include DecimalCode puts DecimalCode.hello puts DecimalCode.code

My queries

  1. What is the difference between the methods "code" and "DecimalCode.code"
  2. When I do not include the module and type "puts DecimalCode.code" it always prints Green: Decimal code, why is that so?