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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:02:26+00:00 2026-06-07T08:02:26+00:00

I am new to ruby, and I have been reading a lot of tutorials.

  • 0

I am new to ruby, and I have been reading a lot of tutorials. Yesterday I SWEAR I read an example of the each statement (or something like it) that enumerated over an array, and then passed a subset of the array to the block. Here’s an example, but the syntax is wrong (or I am using the wrong method) so this will not actually run.

arry = ["a", "b", "c", "d", "e"]

arry.each(3) {|a, b, c| puts a+b+c}

If I was using the right command, this would print:abc bcd cde; it takes the first three members of the array starting at the index and the enumeration ends when there isn’t a string long enough to provide all three arguments. I can’t remember how to do it and I can’t seem to google the right thing to find it. Do any of you guys know?

  • 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-07T08:02:28+00:00Added an answer on June 7, 2026 at 8:02 am

    each_cons(3) behaves like that. It is in Enumerable (Array includes Enumerable), that’s why you couldn’t find it.

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

Sidebar

Related Questions

I'm new with ruby and rails and have been struggling with this issue for
Complete new person to Ruby and Rails here... Have tried some tutorials in the
I'm new to Ruby, and have been working my way through Mr Neighborly's Humble
I am new to Ruby and have been asked to use it in our
I am new to Ruby on Rails and have been helped immensely by Michael
I'm very new to Ruby on Rails, and have been getting the following error
Im new to ruby on rails and i have been following The Rails Space
I have been trying to get the hang of metaprogramming in ruby by reading
I am new to Rails & Ruby and have been following the http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I'm pretty new to Ruby on Rails, forms lately have been giving me all

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.