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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:35:04+00:00 2026-06-01T02:35:04+00:00

Should be an easy one. I thought, from reading this blog post that I

  • 0

Should be an easy one. I thought, from reading this blog post that I could return something right after my next command:

next "new value" if axis_range == "test"

What I’d really like to do is log the reason for the next on the same line:

next @logger.info('skipping this item because for fun') unless (elephants.size > 0)

I can’t find any discussion of this usage of next on ruby doc. The code certainly works. I realize I can do this with an unless block but the that line of code is sooo concise.

Two questions:

  • Is there a better document somewhere?
  • Is this usage of next a little odd and not ‘ruby-ish’?
  • 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-01T02:35:05+00:00Added an answer on June 1, 2026 at 2:35 am

    ” Like the return and break keywords, next may be used alone, or
    it may be followed by an expression or a comma-separated list of
    expressions. When next is used in a loop, any values following
    nextare ignored. In a block however the expression or expressions
    become the “return value” of the yield statement that invoked the
    block.” (The Ruby Programming Language, David Flanagan & Yukihiro Matsumoto, 2008, page 150)

    The book gives this example:

    squareroots = data.collect do |x|
      next 0 if x < 0 # return 0 for negative values
      Math.sqrt(x)
    end
    

    and this alternative:

    squareroots = data.collect do |x|
      if (x < 0) then 0 else Math.sqrt(x) end
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Feel like this should be something easy that I'm missing. I have a table
This should be an easy one. I have a table like so: <table> <tr>
This should be and easy one for the LINQ gurus out there. I'm doing
Good afternoon, This should be an easy one. I've done the cookie-cutter default ASP.NET
This should be easy (at least no one else seems to be having a
At first, I thought this should be very easy. Just use $(selector).val() to get
The one-liner should: solve a real-world problem not be extensively cryptic (should be easy
This should be easy for many of you, but for me it's just another
This should be easy, but I'm not sure how to best go about it.
It should be easy, right? Have a listview, add an imagelist, add images to

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.