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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:44:16+00:00 2026-06-11T17:44:16+00:00

I am new to ruby , can someone explain what the second and 3rd

  • 0

I am new to ruby , can someone explain what the second and 3rd line do?

a = [6,7,8]
a.send :[]=,0,2
a[0] + a.[](1) + a.send(:[],2)

First line is assigning an array to the variable a.

I am totally lost on second and third line. hope someone can give some detail explannations.

Thanks!!!

  • 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-11T17:44:18+00:00Added an answer on June 11, 2026 at 5:44 pm

    .send invokes the method identified by symbol, passing it any arguments specified.

    a.send :[]=,0,2
    

    is same as

    a.send(:[]=, 0, 2)
    

    Means invoke []= method on the array object with first parameter as 0 and second parameter as 2.

    So this is a[0] = 2, set the first element of the array to 2.

    After executed a.send :[]=,0,2, a becomes [2, 7, 8].

    a.[](1) is same as a[1]

    a.send(:[], 2) is same as a.[](2) which is a[2].

    So a[0] + a.[](1) + a.send(:[],2) equals a[0] + a[1] + a[2] equals 2 +7 + 8 equals 17.

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

Sidebar

Related Questions

can someone please help in select helper, as I am new to Ruby On
I am new to ruby and rails. Can someone please point out what is
I am new programmar in Ruby. Can someone take an example about opening file
Am new to ruby. Can any one tell me how to find inverse of
I'm very new to Ruby and using Sinatra, mainly so that I can do
I am very new to Ruby, and was wondering how I can update the
I know I can define new structs in ruby by doing Person = Struct.new(:first_name,
new on ruby and using windows xp and rails 3, i want to send
I'm rather new to Ruby, and today I wrote an application which you can
I'm pretty new in Ruby and Rails. I want to send a HTTP POST

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.