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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:50:06+00:00 2026-05-29T16:50:06+00:00

I have array numbers = [ 1, 2, 3, 4, 5, 6 ] I

  • 0

I have array

numbers = [ 1, 2, 3, 4, 5, 6 ]

I have a variable:

number = 4

I want with a loop for or each block return false unless the number 4 for this case exist in array.

numbers.each do |number_loop| 
    return false unless number_loop == number   
end

But I get an error:

LocalJumpError: unexpected return
from (irb):25:in `block in irb_binding’

  • 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-29T16:50:07+00:00Added an answer on May 29, 2026 at 4:50 pm

    Unless you’re doing something else in the block that you’ve hidden from posting here, why don’t you just do:

    return false if numbers.include? number
    

    As for the reason you get a LocalJumpError there: if your code isn’t in a method then there isn’t anything to return to (or, put another way: nothing to jump back to). In that case you’re probably trying to set a variable rather than return, and you’d want to do:

    is_included = numbers.include? number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of numbers, each one of these number represents weight. the
I have an array of numbers: @numbers = 1,2,3,6,8,9,11,12,13,14,15,20 and I want to print
Lets say I have this array, int[] numbers = {1, 3, 4, 9, 2};
I have an Array of number values, and I want to randomly select a
I have a variable that holds a number var simpleNumber = 012345678; I want
I have a variable that contains an array. That array contains X number of
Let's suppose I have n arrays, where n is a variable (some number greater
Lets say I have an array numbers that contains the following values: int numbers
I have an array of numbers that potentially have up to 8 decimal places
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]

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.