Below are 3 filmnut.org blog posts tagged ruby

Learning Ruby on Rails: Part I - The Language

Most of my programming experience has been in PHP, JavaScript/JQuery, and VB.NET. When I worked in Support at Code Climate, it became obvious to me that I had picked the wrong languages, and that Ruby was the better choice. With its super simple and legible syntax, Gem support, and stellar framework, I was excited to dig in!

A few years back I dabbled in trying to learn Ruby on Rails, but I made the mistake of trying to teach myself both the language and the framework at the same time. That led to mostly confusion and frustration. I've heard many different opinions on this subject, but I now strongly believe that you should have a firm grasp of the language before trying to learn one of its frameworks.

For the past year or so I've been focusing solely on Ruby, primarily by consuming Team Treehouse's Learn Ruby track. It's a 20-hour course in all and I'm stoked to have finally completed it! Next up: Rails!

While moving through the Ruby course I took copious notes. I thought it would be helpful to share those notes here. Enjoy!

Continue reading...

Having Rubocop tell me that my Ruby code is stylistically flawless makes me feel very good. No, really.

Below is a good example of someone brand new to Ruby (me!) and someone with Ruby experience (not me!) solving the exact same problem. These two methods have the same goal: accept a string, reverse and return it.
def solution(sentence)

  sentence_as_array = sentence.split(" ").reverse!

  reversed_string = ""
  sentence_as_array.each do |x|

    reversed_string = reversed_string + x + " "

  end

  return reversed_string.chop

end

def better_solution(sentence)

  sentence.split(" ").reverse.join(" ")

end

It's crazy how much more elegant the second method is.