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 7627129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:25:08+00:00 2026-05-31T05:25:08+00:00

I am experimenting with arrays, and am reading the book Beginning Ruby on Rails

  • 0

I am experimenting with arrays, and am reading the book “Beginning Ruby on Rails” by Steve Holzner. I made the program:

array = ['Hello', 'there', 1, 2]
puts array[1]
puts array[3]
puts array.length
array2 = Array.new
puts array2.length
array2[0] = "Banana"
array2[1] = 6
puts array2[0] + " " + array2[1]
puts array3.length

It doesn’t do much, but when i run it i get the error

arrays.rb:9:in `+': can't convert Fixnum into String (TypeError)
    from arrays.rb:9

Why do I get this error?

  • 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-05-31T05:25:08+00:00Added an answer on May 31, 2026 at 5:25 am

    You can’t add a string and a integer (Fixnum), in this case you tried to add 6 to “Banana”.

    If on line 9 you did this:

    puts array2[0] + " " + array2[1].to_s
    

    You would get:

    "Banana 6"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experimenting with calling delegate functions from a delegate array. I've been able
gcc 4.4.4 c89 I was just experimenting with a int array. And something just
I'm experimenting with SplFixedArray. I have some work done with dynamic arrays which i'm
i am experiencing much trouble reading in files from input into an array struct.
I'm currently experimenting with arrays in PHP, and I created a fake environment where
I'm experimenting with arrays in PHP and I am setting up a fake environment
Okay so I'm fairly new to PHP and I am currently experimenting with arrays.
I was just experimenting with the use of pointers when dealing with arrays and
I'm experimenting with the concept of pointer to multi-dimension array in C. Suppose I
Experimenting with Scala... I'm trying to define something analogous to the @ hack in

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.