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 147673

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:49:21+00:00 2026-05-11T08:49:21+00:00

With certain constructs, I have the choice of using a semicolon or the do

  • 0

With certain constructs, I have the choice of using a semicolon or the do keyword to delimit the end of a statement, as with the until example below.

until x == 100 do puts x; x+=1 end   until x == 100; puts x; x+=1 end  

But this is not possible with Kernel.loop.

x=0     loop do puts x; x+=1; break if x == 100 end  x=0     loop; puts x; x+=1; break if x == 100 end # => error 

Is there a reason why it’s like this?

  • 0 0 Answers
  • 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. 2026-05-11T08:49:22+00:00Added an answer on May 11, 2026 at 8:49 am
    • loop is a method (in Kernel) that really requires a block with do...end or { }.
    • while and until are statements (like if), and do not expect a block. The do keyword is optional, but it does not denote a block (e.g. while x == 100 { puts x; x+=1; } will fail miserably, whereas loop { puts x; x+=1; break if x == 100 } will work just fine.)

    So, do means different things in the two cases. In the case of loop (and other methods) it really denotes a block; in the case of while, until etc. it is just syntactic sugar (just like then is after if.) Do not be misled.

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

Sidebar

Related Questions

i have found that WebBrowser control (both Winforms and WPF) has certain javascript constructs
Certain methods in Java will block until they can do something, like ServerSocket.accept() and
HttpResponse.End() seems to throw an exception according to msdn. Right now i have the
I have a library that programmatically constructs a UIView that exhibits my custom behavior.
I'm trying to implement a cancellable worker thread using the new threading constructs in
I have the following class. Which returns certain fields. I am interested in Reference.
I have some Java (5.0) code that constructs a DOM from various (cached) data
In a certain Java class for a Struts2 web application, I have this line
When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while
I have written a large (to me) grammar using pyparsing to parse H248 message,

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.