Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I encountered this problem today going through Mr. Neighborly's Ruby tutorial, and worked out the answer. It is a known problem with SciTE and the way it interacts with stdin (<code>gets()</code>) on Windows.</p> <p>To run the tutorial code as-is, use the command prompt to run your program, rather than the SciTE 'Go' key [F5] mentioned in Mr. Neighborly's Humble Little Ruby Book, as follows:</p> <h2>Workaround 1:</h2> <ol> <li>Your Windows Ruby installation should include a shortcut (under the Start menu) called "Start Command Prompt with Ruby". Run that.</li> <li>In the Ruby command prompt, navigate to the path where your Hello World Ruby file is located.</li> <li>Type <code>ruby hello.rb</code> and press [Enter]. (Replace <code>hello.rb</code> with your file name.)</li> </ol> <h2>Workaround 2:</h2> <p>Another alternative is to ignore the broken command prompt, and use SciTE's internal one instead. But, this requires you to add <code>$stdout.flush()</code> after each <code>puts()</code> statement, like this:</p> <pre><code>puts "Hello, world. What is your name?" $stdout.flush() # Add this line! myname = gets() puts "Well, hello there " + myname + "." $stdout.flush() # Add this line! </code></pre> <h2>Note</h2> <p>The next inconsistency in Chapter 0 of the tutorial, which you will probably notice immediately, is that the newline (\n) character is included in your <code>myname</code> variable (the input from <code>gets()</code>). You will probably see the following output (note the "." on the second line):</p> <pre><code>Well, hello there Yournamehere . </code></pre> <p>To fix this, change <code>myname.gets()</code> to <code>myname.gets().chomp()</code>. (Feel free to look up chomp() in the online Ruby documentation.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload