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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:46:16+00:00 2026-06-14T19:46:16+00:00

In some code I’m trying to learn from, the Maze string below is turned

  • 0

In some code I’m trying to learn from, the Maze string below is turned into an array (code not shown for that) and saved in the instance variable @maze. The starting point of the Maze is represented by the letter ‘A’ in that Maze, which can be accessed at @maze[1][13]—row 1, column 13. However, the code I’m looking at uses @maze[1][13,1] to get the A, which you can see returns the same result in my console. If I do @maze[1][13,2], it returns the letter “A ” with two blank spaces next to it, and so on. [13,3] returns “A ” with three blank spaces.

Does the 2 in [13,2] mean, “return two values starting at [1][13]? If so, why? Is this some feature of arrays or two dimensional arrays that I don’t get?

[20] pry(#<Maze>):1> @maze[1][13]
=> "A"
[17] pry(#<Maze>):1> @maze[1][13,1]
=> "A"
[18] pry(#<Maze>):1> @maze[1][13,2]
=> "A "
[19] pry(#<Maze>):1> @maze[1][13,3]
=> "A  "

Maze String

MAZE1 = %{#####################################
# #   #     #A        #     #       #
# # # # # # ####### # ### # ####### #
# # #   # #         #     # #       #
# ##### # ################# # #######
#     # #       #   #     # #   #   #
##### ##### ### ### # ### # # # # # #
#   #     #   # #   #  B# # # #   # #
# # ##### ##### # # ### # # ####### #
# #     # #   # # #   # # # #       #
# ### ### # # # # ##### # # # ##### #
#   #       #   #       #     #     #
#####################################}
  • 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-14T19:46:17+00:00Added an answer on June 14, 2026 at 7:46 pm

    From what you show, it seems that @maze is not a two-dimentional array, but is an array of strings. @maze[1] is a string. The second [] is applied to a string. And the second argument of String#[] method describes the length of characters to take. You can consider that it is defaulted to 1 when you do not specify it. By the way, your question is wrong. You describe

    If I do @maze[1][13,2], it returns the letter “A ” with two blank spaces next to it, and so on.

    but what your example shows is

    If I do @maze[1][13,2], it returns the letter “A ” with one blank space next to it, and so on.

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

Sidebar

Related Questions

Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
Some code here, I want store mysql query result into an array with php,
I have some code that I'm updating to C++11 using gcc 4.7 (from 3.1)
Some code that I don't have control over is overriding the global JSON object
first some code: I have many elements like that: <section class=item> <div class=caption> </div>
Some code that I had that used attr_accessor_with_default in a rails model is now
Consider some code that calls, say, file = new RandomAccessFile(x, r); file.getChannel().map(....) and wants
Doing some code reading and stumbled upon this snippet that I haven't seen before:
Some code instead of a long explanation. The problem is : When called from
In some code that I've recently inherited the responsibility for, I've found several instances

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.