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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:04:41+00:00 2026-06-09T09:04:41+00:00

In a very simple program trying to use each I get the error :

  • 0

In a very simple program trying to use “each” I get the error : sum.rb:16: undefined method `each’ for # (NoMethodError)

I get the same error using “each” various ways: the one shown below was copied directly from the Class:Matrix from ruby-doc.org.

# create State database using matrix
require 'matrix'

State=Matrix[ [3,1,4,4,6,2,8,12,6,2],
        [6,2,4,13,25,21,11,22,9,3,],
        [6,20,27,34,22,14,12,11,2,5],
        [6,28,17,23,31,18,15,9,18,12],
        [9,18,11,13,8,27,10,14,24,11],
        [3,9,7,16,9,15,28,24,29,21],
        [5,8,4,7,17,14,19,30,33,4],
        [7,17,23,9,5,9,22,21,12,21,],
        [7,14,25,22,16,10,19,15,12,11],
        [5,16,7,3,6,3,9,8,1,5] ]

State.each { |e| puts e }

This must be simple/obvious but I can’t figure it out. (I’ve already done a variety of things with the State matrix that work out as expected.)

  • 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-09T09:04:43+00:00Added an answer on June 9, 2026 at 9:04 am

    Ruby 1.8.7 will return the problem you are seeing. The Matrix object in 1.8.7 doesn’t have an each method.

    Upgrading to a recent version, either 1.9.2 or 1.9.3 will fix the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use AppWeb, and i wrote a very simple program to embed
I am trying a very simple use of JavaFX using a simple set of
I'm trying to write a very simple program, I want to print out the
I am running a very simple program, which is trying to list files in
I'm trying to write a very simple image processing program for fun and practice.
Here's a very simple program using the function: #include <windows.h> #include <tchar.h> #include <atlstr.h>
I am trying to use SciPy to solve a very simple equation (Kepler's equation)
I am trying to use priority_queue, and program constantly fails with error message HEAP
I am currently trying to make a very simple C program for school that
I am trying to cross-compile a very simple program for Android that worked with

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.