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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:13:00+00:00 2026-05-15T23:13:00+00:00

I recently ran into code that looks like this: next { ‘foo’ => bar,

  • 0

I recently ran into code that looks like this:

 next {
          'foo'         => bar,
          'foobar'      => anotherbar,
      }

At first it looks like a simple hash, but there is no assignment to next. Next in this case looks like a reserved Ruby keyword. What does this code do?

  • 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-05-15T23:13:00+00:00Added an answer on May 15, 2026 at 11:13 pm

    next is similar to the continue keyword in the c family of languages, except in ruby it makes an iterator move to the next iteration. Since blocks always have some sort of return value you can choose to pass one as an argument to next.

    next is typically used in cases like iterating through a list of files and taking action (or not) depending on the filename.

    next can take a value, which will be the value returned for the current iteration of the block.

      sizes = [0,1,2,3,4].map do |n|
        next("big") if n > 2
        puts "Small number detected!"
        "small"
      end
    
      p sizes
    
    Output:
    
      Small number detected!
      Small number detected!
      Small number detected!
      ["small", "small", "small", "big", "big"]
    

    from http://ruby-doc.org/docs/keywords/1.9/

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

Sidebar

Related Questions

I recently ran into a piece of code very much like this one: var
I've recently ran into some code that checks Page.IsCallBack but I wasn't sure how
I ran into a problem recently and found out that this is a bona-fide
I recently ran into a bug in my code when using boost::bind . From
A problem I recently ran into was that when trying to update a field
I recently ran into some issues with android.os.Bundle that I hoped to fix by
Premise I recently ran into a bug in a select statement in my code.
I ran into an unexpected code optimization recently, and wanted to check whether my
I recently ran into gwan ( http://gwan.ch ) a free web server that according
I recently ran into an issue where I used a property that was introduced

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.