Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 105209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:24:11+00:00 2026-05-11T01:24:11+00:00

I have recently learned the Ruby programming language, and all in all it is

  • 0

I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the ‘rule of least-surprise’ did not seem very respected to me (of course this is quite subjective). For example:

x = true and false puts x  # displays true! 

and the famous:

puts 'zero is true!' if 0  # zero is true! 

What are the other ‘Gotchas’ you would warn a Ruby newbie about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:24:12+00:00Added an answer on May 11, 2026 at 1:24 am

    Wikipedia Ruby gotchas

    From the article:

    • Names which begin with a capital letter are treated as constants, so local variables should begin with a lowercase letter.
    • The characters $ and @ do not indicate variable data type as in Perl, but rather function as scope resolution operators.
    • To denote floating point numbers, one must follow with a zero digit (99.0) or an explicit conversion (99.to_f). It is insufficient to append a dot (99.), because numbers are susceptible to method syntax.
    • Boolean evaluation of non-boolean data is strict: 0, '' and [] are all evaluated to true. In C, the expression 0 ? 1 : 0 evaluates to 0 (i.e. false). In Ruby, however, it yields 1, as all numbers evaluate to true; only nil and false evaluate to false. A corollary to this rule is that Ruby methods by convention — for example, regular-expression searches — return numbers, strings, lists, or other non-false values on success, but nil on failure (e.g., mismatch). This convention is also used in Smalltalk, where only the special objects true and false can be used in a boolean expression.
    • Versions prior to 1.9 lack a character data type (compare to C, which provides type char for characters). This may cause surprises when slicing strings: 'abc'[0] yields 97 (an integer, representing the ASCII code of the first character in the string); to obtain 'a' use 'abc'[0,1] (a substring of length 1) or 'abc'[0].chr.
    • The notation statement until expression, unlike other languages’ equivalent statements (e.g. do { statement } while (not(expression)); in C/C++/…), actually never runs the statement if the expression is already true. This is because statement until expression is actually syntactic sugar over

      until expression   statement end 

      , the equivalent of which in C/C++ is while (not(expression)) statement; just like statement if expression is an equivalent to

      if expression   statement end 

      However, the notation

      begin   statement end until expression 

      in Ruby will in fact run the statement once even if the expression is already true.

    • Because constants are references to objects, changing what a constant refers to generates a warning, but modifying the object itself does not. For example, Greeting << ' world!' if Greeting == 'Hello' does not generate an error or warning. This is similar to final variables in Java, but Ruby does also have the functionality to ‘freeze’ an object, unlike Java.

    Some features which differ notably from other languages:

    • The usual operators for conditional expressions, and and or, do not follow the normal rules of precedence: and does not bind tighter than or. Ruby also has expression operators || and && which work as expected.

    • def inside def doesn’t do what a Python programmer might expect:

      def a_method     x = 7     def print_x; puts x end     print_x end 

      This gives an error about x not being defined. You need to use a Proc.

    Language features

    • Omission of parentheses around method arguments may lead to unexpected results if the methods take multiple parameters. The Ruby developers have stated that omission of parentheses on multi-parameter methods may be disallowed in future Ruby versions; the current (November 2007) Ruby interpreter throws a warning which encourages the writer not to omit (), to avoid ambiguous meaning of code. Not using () is still common practice, and can be especially nice to use Ruby as a human readable domain-specific programming language itself, along with the method called method_missing().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 57k
  • Answers 57k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer SQLEditor is pretty minimalistic, easy to use and supports exporting… May 11, 2026 at 8:24 am
  • added an answer Search and replace (case insensitive, regular expression): http://www\.mysite\.com/([^/]*\.(?:jpg|gif|png)) with: http://www\.NEW_WEBSITE\.com/\1… May 11, 2026 at 8:24 am
  • added an answer Here's a very simple example of how to do this… May 11, 2026 at 8:24 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.