Fork me on GitHub
Not logged in • Login

Frequently Asked Questions

No, for the reason that there is no "better" language than another. Ruby can be more fitted in certain tasks, whereas it can also be problematic in other areas. It all depends on a large number of parameters.
It depends on many parameters. Ruby is a general purpose language which can achieve anything. Then, deciding on if you should use it or not is all up to you, but know that there is no good answer to this question.
Ruby is an interpreted language, so it will be slower than native languages as C, but will be close to Python or Perl. Ruby is fast to write, it can save you a lot of time in development compared to C or Java.
This kind of question is rarely useful, just describe your issue directly.
Ruby is around for a long time, well over 20 years already, major companies depend on it, it is actively developed and available in the repositories of every major distribution. No, Ruby will not go away anytime soon.
#ruby is targeted at general Ruby discussion. If your question targets Ruby on Rails framework, please ask in #RubyOnRails (Channel requires registration to join).
Anything that can edit text, when combined with a terminal, will do. Editor choice is is a personal preference, try a few out and stick with what you like the most. Reevaluate every couple of years if your chosen editor still fits your workflow or if there are new contenders that suit you better. That said, vim and Sublime Text are the most popular choices, Ruby Mine is the most popular full-featured IDE.

There are multiple ways of getting ruby.

  • On Linux, use your system package manager.
  • On Windows, you can use Ruby installer.
  • OS X comes with a pre-installed Ruby version.

However, you can also use solutions like RVM or rbenv to manage multiple and/or more recent ruby versions at once easily. For more information, see the official documentation.

A literal is an object where its value is literally in the code. Examples: 123, "Hello", []. Examples of non-literal values: string = gets, hash = JSON.parse(value), sum = a + b"
It's part of Symbol literal. Just like the quotes are part of a String literal.
They delimit the arguments a block accepts. Much like in `def foo(argument)` the () delimit the arguments the method takes.
It's part of stabby lambda syntax
It's part of the variable name. It means it is an instance variable. Instance variables are scoped per Object. This means any method called on the same object will see the same instance variable.
You can get a callable object from a method by calling #method on the object, for example "hello".method(:length). You obtain a method object which behaves like a Proc which you can pass to other functions.

They refer to equivalent as booleans. Boolean is a type which can only take two values: true and false.

When we use the terms "truthy" and "falsy", we refer to the equivalent as a boolean value that an expression will have, which is used by control flow statements like if or while and filtering methods like Enumerable#select.

Only two values are falsy, meaning that they will be interpreted as false: nil and false. Any other value, including 0, will be truthy and be treated as true.

The || operator returns the argument which is truthy. In this case, "b" == "a" evaluates to false, but "b" evaluates to true, so "b" is returned.

See also the "What does "truthy" and "falsy" means?" answer.

That's a unicode replacement character. This most likely means that you have read data from a source which is NOT unicode, but treated it as unicode. You get rid of this by figuring the source's encoding, read the data using that encoding, and then re-encoding to e.g. utf-8 by using String#encode. Mandatory encoding article.
You can use either String#delete or String#gsub.
Use `string[-N, N]`. Example: `"hello"[-3,3] # => "llo"`
Your Array consists of 5 times the same Array. Use `ary = { [] }` instead, which populates your Array with different Arrays.
`hash[:key] << 12`, nothing is stored in the Hash, why? A: `hash[:key]` returns the default value, and you push on that default value. Create your Hash like this instead: `hash = { |hash, key| hash[key] = [] }`.
`3/2` is an Integer division and returns an Integer. Depending on your needs and your context, you can do any of `3.quo(2)` (will return a Rational), `3.fdiv(2)` (will return a Float), `3.0/2` (will return a Float too) or `3/2.0` (will also return a Float).
Welcome to the world of floats. Floats have a fixed size and therefore a limited precision. If we inspect the values more closely using `printf "%.60f\n%.40f\n", 0.1+0.2, 0.3`, we see that the values of those expressions are `0.300000000000000044408920985006261616945266723632812500000000` and `0.299999999999999988897769753748434595763683319091796875000000`. They differ subtly, but they do differ and hence are not ==. In general, you should compare floats by using a delta comparison. Example: `(a - b).abs < delta`. You have to choose a delta which suits your specific situation. Alternatively use something else than floats. Ruby has implementations of Integer, Rational and BigDecimal, which all might satisfy your needs.