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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:12:17+00:00 2026-06-04T12:12:17+00:00

Lines 4 & 5 are causing me grief: 1 def test_break_statement 2 i =

  • 0

Lines 4 & 5 are causing me grief:

1  def test_break_statement
2     i = 1
3     result = 1
4     while true
5       break unless i <= 10
6       result = result * i
7       i += 1
8     end
9     assert_equal 3628800, result
10  end

I’m not sure what needs to remain true in the while true statement, however I believe it is the code that follows it. This leads to further confusion because I am reading the line:

break unless i <= 10 as break if i is not smaller or equal to 10. What procedure is this code going through ie how does the while and break statements interplay. I think I am nearly there but can’t put the process in my head. Thanks.

  • 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-04T12:12:19+00:00Added an answer on June 4, 2026 at 12:12 pm

    while statements test whatever comes after the word while. If the expression that follows them is true they execute the code within the loop. If the expression is false, they do not.

    Thus, as other posters have pointed out, while true will always execute the code within the loop. Luckily for your code there is a break statement within the loop. If there wasn’t, the loop would run forever and you’d have to kill the process running your program.

    In your code sample the break keyword is followed by unless which means that it will break the loop unless the expression following it is true. Your code will break out of the loop when i is greater than 10.

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

Sidebar

Related Questions

I have the following lines of code: if(std::binary_search(face_verts.begin(), face_verts.end(), left_right_vert[0]) && std::binary_search(face_verts.begin(), face_verts.end(), left_right_vert[1]))
Declare: LPWSTR** lines= new LPWSTR*[totalLines]; then i set using: lines[totalLines]=&totalText; SetWindowText(totalChat,(LPWSTR)lines[totalLines]); totalLines++; Now I
This line is causing segfault to me: 30 printf(st_name:\t%s\n, &p_str_tab[p->st_name]); I've tried to trace
I'm not sure what could be causing this. ==18270== Invalid free() / delete /
lets say i have two pages links.html & contents.php ... first page contains only
What does this line (x = n & 5;) mean in the code below?
Hard-to-read-line @daily export sunshine=~/logs/Sunshine-`date '+\%F'` && export sunshineUrl=http://www.sunshine.net/main/search_results.asp?currency_id=1&min_price=&max_price=50000&country_id=241&region_id=&Submit=Search && mkdir -p $sunshine && cd
I recently came along this line of code: CustomData_em_free_block(&em->vdata, &eve->data); And I thought, isn't:
few links on Internet (ex: http://drdobbs.com/article/print?articleId=232300575&siteSectionName= http://www.hydrogenaudio.org/forums//lofiversion/index.php/t74268.html ) point out that there is a
I have links like these that I want to change: mypage.com?page=missions&id=5 mypage.com?page=hello I tried

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.