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

  • SEARCH
  • Home
  • 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 9019997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:54:10+00:00 2026-06-16T04:54:10+00:00

I am doing the Ruby Monk tutorial and got stuck on a problem. Here

  • 0

I am doing the Ruby Monk tutorial and got stuck on a problem. Here it is:

“Write a method called add_two that adds 2 to any number passed to it and returns the result. Yes, please feel free to experiment using next in addition to the more obvious route of simply adding the integer 2 to the incoming number.”

I started with:

def add_two(number)
 number + number
end

But i am not sure how to account for negative numbers

Any help would be great!

  • 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. Editorial Team
    Editorial Team
    2026-06-16T04:54:13+00:00Added an answer on June 16, 2026 at 4:54 am

    Basically what they are asking you to do is to use next which is a method of the Integer class.

    Ruby API – Integer#next

    It should look something like this

    def add_two(number)     
      number.next.next
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing the Ruby Monk tutorial to further some ruby learning and I got
Im doing Michael Hartl's excellent tutorial series on ruby on rails here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I'm doing some animation script in RPG Maker XP (made with ruby) that allow
I'm doing the Ruby on Rails Tutorial and am at 1.2.4 Bundler, where I
I was doing the Ruby on Rails tutorial by Martl and closed my terminal
What's the proper way of doing this in Ruby? def callOrElse(obj, method, default) if
Currently doing the Ruby On Rails Tutorial by Michael Hartl, and am starting on
I am doing the Ruby on Rails Tutorial and am up to Listing 6.29
I'm doing the Ruby 20 minute tutorial on ruby-lang.org and I came across this
I'm doing a project in Ruby, and I want to be able to write

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.