Ruby General

Not learning Ruby is a bit like knowing how to fly a plane…on the ground.
Without Ruby, there is no Rails. Ruby is the backbone. It would be wise to have a reasonably solid Ruby foundation before adding on Rails. After that you will hit a certain point where you’ll realize that, in order to enact a desired feature for your web app, you’ll need to apply more advanced Ruby tactics. This will also come into play when trying to understand other developer’s code. As you move further down your Ruby learning path, your eyes will open wider to how much you can do with Ruby, and all the elegant and clever ways people apply Ruby to accomplish a given task. You will want to remember these. This stack is dedicated to capturing these moments of Ruby enlightenment.

Using the .class method to determine if an object is what you are looking for

05/28/15  Public, Tricks, Ruby General

Let's say that you want to use a given object if the object is an array; however, if the object is not an array (meaning it is a string, or a fixnum, etc.), then you do not want to use it.

You can use the .class method with conditional l...

1 vote - harrylevine

Array.map shortcut

05/24/15  Public, Ruby General

In Ruby code, you quite often see the trick of using an expression like:
array.map(&:method_name) as a shorthand form of
array.map { |element| element.method_name }

From: http://www.toptal.com/ruby/interview-questions

1 vote - harrylevine

Ideal code description

03/14/15  Public, Ruby General

In most cases, our idea of ideal code is simple, readable, maintainable, and modular.

-Exercisim.io

1 vote - harrylevine

Viewing the available methods for a given object

12/10/14  Public, Ruby General

As soon as an object comes into existence, it already responds to a number of messages. Every object is "born" with certain innate abilities. For example, if you have a class called Dog, and you create a new object like this, from the command ...

1 vote - harrylevine

Great tutorial on Regular Expressions

12/10/14  Public, Ruby General

RubyLearning.com tutorial on Regular Expressions

1 vote - harrylevine