Category Archives: Codecademy

Ruby Blocks, Procs & Lambda’s

Blocks Procs & Lambda's in RubyAfter completing the Ruby course in Treehouse, I have to be honest. I was feeling discouraged. Treehouse’s video format can be excellent, but I felt that it rushed through a lot of Ruby syntax and didn’t test me enough to make sure I understood it. (Multiple choice tests are the easiest things to scam in the world, especially in Treehouse where often the word your are looking for as an answer is actually in the question.)

ANYWAY, I did the Ruby course and felt like I had no idea what was going on – especially when they spoke about blocks. What did they mean? A block is just a bit of code right? But what makes it different from any other bit of code? And what on earth are Procs and Lambdas?

So, after I did the Treehouse course, I decided to go back to Codecademy and do their Ruby course – and you know what? I feel like that really cemented it in my brain. I feel like I understand it – even procs and lambdas.

Here is my summary

Blocks

These are a bit of code, and they can be contained in EITHER

do…end

OR

{ }

Treehouse did not explain this clearly, so I had no idea that these two different syntax (es? ie?) were the same thing. On Stack Overflow I read that {} is good for one-line code, and otherwise use do..end – although that is just a forum, so who knows how truthful that is.

You can pass these blocks to some methods like .each{put a block here I think}

Procs

A proc is a block which can be saved as a variable and used over and over.

variable = Proc.new do |x|

Do whatever

end

Lambda

A lambda is like a proc, only it cares about the number of arguments it gets (a proc doesn’t care, it will return nil if it doesn’t have the right number of arguments). Also a lambda returns to its calling method and keep executing code, while a proc will return straight after it is run (i.e. it will leave the method and execute no more code).

I don’t feel that Treehouse explained that very well to me, but Codecademy did it in a really easy way.  So, my big recommendation to other beginners in Ruby – do the combination of Treehouse and Codecademy. (Or maybe just Codecademy if you have no money, because Treehouse is subscription only. Maybe I would have understood well enough with just codecademy, the Ruby chapter is really good).

 

Leave a reply

Codecademy’s down, so I bought a Treehouse Subscription

treehouse1So, for the last 45 days, while I have been using some other online learning tools in bits and pieces, mostly I have been obsessed with Codecademy. This was almost completely because of the streak feature, which I had become obsessed with.

Unfortunately, yesterday, the Codecademy site went down, and I lost a bit of my streak. It’s a completely free site, so I didn’t get mad, but I did get a bit anxious because of my crazy attachment to this streak. They were super apologetic, and the streak isn’t back yet – but I wondered if people would really get mad, I mean, it’s free! But then i thought about how hard Codecademy is pushing the angle of points, streaks and badges  - so I guess losing them is a bit of a deal.

In the meantime, I thought I would find some online tutorials about Excel Visual Basic so that I could do some stuff for my actual job…while learning a bit of coding. So, yesterday I did some learning, and even started writing a blog post about VBA… you’ll notice it isn’t up yet, because I got distracted…by Valentines Day!

A place called App Sumo did a 90% off Valentines Day sale (????) for Treehouse – a competitor to Codecademy. It was only $49 for the year, for the gold package – so I signed up…and have now gotten distracted from both VBA and codecademy. Why? Because the interface of Treehouse is just so good! From their cool introduction video (quirky, full of personality) to the variety of courses. The interface is colourful and inviting, and there just seems to be so much content available. (Is this what happens when you actually pay for content? Ohhhhh….)

TreeHouse online learning

Already I can see a PHP course I want to do (not available in codecademy), as well as courses to better understand CSS (it confuses me), and even some design tutorials (I am not a designer, but I do need to learn the basics).

The only thing I would improve about it so far is 1. Let me dogtag some of these courses so I remember I want to do them  - kind of like the queues you can create in Lynda.

2. While there are two cool intro videos – after that I am lost. I don’t know where to start…there is all so much information, and I don’t know which course to choose. Codecademy’s CodeYear was good because it led me down a specific path (while also allowing you to deviate if you want). I would like Treehouse to offer a recommended track, especially for beginners. Lynda is kind of like TreeHouse in that it is just heaps of courses, and there is no particular recommended order. I don’t like that too much.

The other bizarre thing in Treehouse is that there is a ‘business’ course section – which is all about running a business. It seems a bit out of place….but maybe it just means that TreeHouse will be eventually transitioning towards some kind of Lynda programme.

So – I guess I’m going to be in TreeHouse all weekend!

 

 

Leave a reply

Congratulations to Me!

Congratulations 40 days on Codecademy

Today marks a 40 day streak on Codecademy! I have finished HTML, JavaScript and jQuery and I am halfway through Python. (Note that I didn’t start Codecademy 40 days ago, it is just my longest streak, which I started January 1 this year).

I have also done one API course – the YouTube one – but it was very short and I didn’t think it was very useful, so I don’t count it yet. Once I am finished all the other courses (Only Ruby to go after Python), and then have done the Projects…then I might do the other APIs.

If we’re going to be honest, I can’t believe an hour a day for 40 days hasn’t gotten me further – but oh well, it just means I need to stick with it.

I have enjoyed it so far, but must get into putting it into practice, because while Codecademy is very fun, I won’t know I can use it until I actually start implementing what I have learnt (although, being able to more easily understand JavaScript has already helped me at work).

Leave a reply

Codecademy 26 Day Streak

codecademy

I wonder what percentage of  blogs are born of new year’s resolutions?  Not that that is my reason for starting a blog (I already have one for my travels, it languishes). No, my 2013 resolution(I only ever commit to one per year, easier to remember) – is to learn coding/programming and try and do at least some little bit every day.

In relation to that, check out my current streak on Codecademy. I started on January 1st and have done at least a little bit each day. I don’t care too much about points, or badges, but for some reason this streak is having me coming back for more.

I actually started Codecademy last year. 2012 was their ‘Code Year’ and they had a lot of promotion going around about their free course – so much so that I think even the Mayor of NYC signed up. Anyway – coding was something I had been learning bits and pieces of for ages so I thought it would be good to try.

I actually loved their interface, although many of their original drafts of the lessons have since been usurped by better versions. Their jQuery course especially has improved, the first iteration was way too confusing and almost had me quitting, while the new course I found almost too easy.

Doing a bit of Codecademy each day is not hard – all you need to do to keep your streak going is to do one exercise and get one point. In some cases, this could take as little as two minutes, so it is an easy thing to keep up with. I also put an alarm on my phone each day to make sure I don’t lose my streak (overkill? Why do I care about this again?).

 

 

 

Leave a reply