Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>I am thinking more along the lines of Ruby, ...</p> </blockquote> <p>Well for Ruby the <code>irb</code> interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:</p> <ul> <li><p><em>Automation</em>. You are allowed a <code>.irbrc</code> file that will be automatically executed when launching irb. That means you can load your favorite libraries or do <em>whatever</em> you want in full Ruby automatically. To see what I mean check out some of the ones at <a href="https://web.archive.org/web/20110824004021/http://dotfiles.org:80/.irbrc" rel="nofollow noreferrer">dotfiles.org</a>.</p></li> <li><p><em>Autocompletion</em>. That even makes writing code easier. Can't remember that string method to remove newlines? <code>"".ch&lt;tab&gt;</code> produces chop and chomp. <em>NOTE: you have to enable autocompletion for irb yourself</em></p></li> <li><p><em>Divide and Conquer</em>. irb makes the small things really easy. If you're writing a function to manipulate strings, the ability to test the code interactively right in the prompt saves a lot of time! For instance you can just open up irb and start running functions on an example string and have working and tested code already ready for your library/program. </p></li> <li><p><em>Learning, Experimenting, and Hacking</em>. Something like this would take a very long time to test in C/C++, even Java. If you tried testing them all at once you might seg-fault and have to start over.</p> <p>Here I'm just learning how the <code>String#[]</code> function works.</p> <pre><code>joe[~]$ irb &gt;&gt; "12341:asdf"[/\d+/] # =&gt; "12341" &gt;&gt; "12341:asdf"[/\d*/] # =&gt; "12341" &gt;&gt; "12341:asdf"[0..5] # =&gt; "12341:" &gt;&gt; "12341:asdf"[0...5] # =&gt; "12341" &gt;&gt; "12341:asdf"[0, ':'] TypeError: can't convert String into Integer from (irb):5:in `[]' from (irb):5 &gt;&gt; "12341:asdf"[0, 5] # =&gt; "12341" </code></pre></li> <li><p><em>Testing and Benchmarking</em>. Now they are nice and easy to perform. <a href="http://ozmm.org/posts/time_in_irb.html" rel="nofollow noreferrer">Here</a> is someone's idea to emulate the Unix <code>time</code> function for quick benchmarking. Just add it to your <code>.irbrc</code> file and its always there!</p></li> <li><p><em>Debugging</em> - I haven't used this much myself but there is always the ability to debug code <a href="https://web.archive.org/web/20080912141043/http://www.rubycentral.com:80/pickaxe/trouble.html" rel="nofollow noreferrer">like this</a>. Or pull out some code and run it in the irb to see what its actually doing.</p></li> </ul> <p>I'm sure I'm missing some things but I hit on my favorite points. You really have zero limitation in shells so you're limited only by what you can think of doing. I almost always have a few shells running. Bash, Javascript, and Ruby's irb to name a few. I use them for a lot of things!</p>
 

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