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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:24:55+00:00 2026-06-12T04:24:55+00:00

I understood it that Ruby stdlib Matrix is not modifiable, that is, for eg.

  • 0

I understood it that Ruby stdlib Matrix is not modifiable, that is, for eg.

m = Matrix.zero( 3, 4 )

one cannot write

m[0, 1] = 7

But I would like to do it so much… I can do it with awkward programming, such as

def modify_value_in_a_matrix( matrix, row, col, newval )
  ary = (0...m.row_size).map{ |i| m.row i }.map( &:to_a )
  ary[row][col] = newval
  Matrix[ *ary ]
end

…or with cheating, such as

Matrix.send :[]=, 0, 1, 7

, but I wonder, this has to be a problem that people encounter all the time. Is there some standard, customary way of doing this, without having to rape the class using #send method?

  • 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-12T04:24:57+00:00Added an answer on June 12, 2026 at 4:24 am

    You can open the class and def your own method to do this:

    class Matrix
      def []=(i, j, x)
        @rows[i][j] = x
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently designed a web application that I would like to write in
Please understand that I'm not trying to bash RVM. I would just like to
I've understood that a network operation is not allowed on the GUI thread. Ok
I am building a small activex control. I understood that activex cannot call a
I've played around with IronRuby lately, but I would like to install the reference
I recently started learning ruby, and I understood that you coud use code blocks
I know that I can write a Ruby case statement to check a match
Having recently started programming in Ruby, I noticed one small language feature that is
I understand that in order to sum array elements in Ruby one can use
I am using Ruby on Rails 3 and I would like to send 'email'

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.