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

Java Java Data Structures Getting There Class Review

Noah Schill
Noah Schill
10,020 Points

Anyone else keep dropping colons?

After completing the android track, completing the iOS with swift track, and then coming back to this, Swift has taught me to not use colons. So frustrating!! xD Anyone else having similar issues after using Python or other languages?

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

Yep! I've been learning PHP after learning Swift, and I leave off semicolons all over the place!

Hi Noah and Greg,

Things only get uglier when you have to deal with Ruby what uses..

(drum roll please)

double colons :anguished:

: :

Some related (explanatory) quotes..

The :: is a unary operator that allows: constants, instance methods and class methods defined within a class or module, to be accessed from anywhere outside the class or module.

Per this page:

http://marcricblog.blogspot.com/2007/11/ruby-double-colon.html

When a receiver is explicitly specified in a method invocation, it may be separated from the method name using either a period “.” or two colons “::”. The only difference between these two forms occurs if the method name starts with an uppercase letter. In this case, Ruby will assume that a receiver::Thing method call is actually an attempt to access a constant called Thing in the receiver unless the method invocation has a parameter list between parentheses.

per this page:

http://phrogz.net/programmingruby/language.html

It's called a scope resolution operator. Basically a fancy way of referencing a class within a namespace.

per this StackOverFlow thread:

http://stackoverflow.com/questions/2276905/what-does-double-colon-mean-in-ruby


Long story short:

That's twice as many opportunities to drop a colon! alt text

Noah Schill
Noah Schill
10,020 Points

;A; I'm looking into Ruby dev. Thanks for the preparation. I am now sufficiently terrified xD.