# Irb freaks out over a case stmt

**URL:** <https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833>\
**Category:** Ruby\
**Created:** [September 15, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833 "2006-09-15T19:59:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 15, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/1 "2006-09-15T19:59:55Z")

</div>

i’m writing a method within the Akill class that cascades down 2 sql  
stmts inside some if and when stmts…but i get this when i added the  
last branch of if stmts: what happened note : ALL ‘end’ stmts are  
properly matched

> > class Akill  
> > def getusd(prem,cust,serv,scat,readit)  
> > cursor=@@conn.exec("\<\>\>")  
> > k=Array.new  
> > while r=cursor.fetch() and k.size\<3  
> > k.push®  
> > end  
> > cursor.close  
> > if k.size\>0  
> > k.first  
> > else  
> > ?\> cursor=@@conn.exec("\<\>\>")
> 
> > ```
> > k=Array.new
> > while r=cursor.fetch() and k.size<3
> > k.push(r)
> > end
> > cursor.close
> > if k.size>0
> > k.first
> > else
> > 
> > ```

?\> #get defaults of kwd=0,kvar=700,kwh=1500  
?\> #else nil  
?\> case scat

> > ```
> > when scat=='KWH' 1500
> > 
> > ```

Display all 459 possibilities? (y or n)  
== SecurityError  
=== Signal  
=~ SignalException  
ARGF SimpleDelegater  
ARGV SimpleDelegator  
Akill SingleForwardable  
ArgumentError SizedQueue  
Array StandardError  
BEGIN String  
Bignum Struct  
Binding Symbol  
CROSS\_COMPILING SyntaxError  
Class SystemCallError  
Comparable SystemExit  
ConditionVariable SystemStackError  
Config TOPLEVEL\_BINDING  
Continuation TRUE  
Data Tempfile  
Date Thread  
DateTime ThreadError  
DelegateClass ThreadGroup  
Delegater Time  
Delegator TrueClass  
–Mor\>\> scat==‘KVAR’ 700

> >

Display all 459 possibilities? (y or n)  
== SecurityError  
=== Signal  
=~ SignalException  
ARGF SimpleDelegater  
ARGV SimpleDelegator  
Akill SingleForwardable  
ArgumentError SizedQueue  
Array StandardError  
BEGIN String  
Bignum Struct  
Binding Symbol  
CROSS\_COMPILING SyntaxError  
Class SystemCallError  
Comparable SystemExit  
ConditionVariable SystemStackError  
Config TOPLEVEL\_BINDING  
Continuation TRUE  
Data Tempfile  
Date Thread  
DateTime ThreadError  
DelegateClass ThreadGroup  
Delegater Time  
Delegator TrueClass  
–Mor\>\> scat==‘KWD’ 0

> >

Display all 459 possibilities? (y or n)  
== SecurityError  
=== Signal  
=~ SignalException  
ARGF SimpleDelegater  
ARGV SimpleDelegator  
Akill SingleForwardable  
ArgumentError SizedQueue  
Array StandardError  
BEGIN String  
Bignum Struct  
Binding Symbol  
CROSS\_COMPILING SyntaxError  
Class SystemCallError  
Comparable SystemExit  
ConditionVariable SystemStackError  
Config TOPLEVEL\_BINDING  
Continuation TRUE  
Data Tempfile  
Date Thread  
DateTime ThreadError  
DelegateClass ThreadGroup  
Delegater Time  
Delegator TrueClass  
–MorDir TypeError  
END UnboundMethod  
ENV VERSION  
EOFError Win32API  
Enumerable ZeroDivisionError  
Errno \_  
Exception **id**  
Exception2MessageMapper **send**  
FALSE `  
FalseClass abort  
File alias  
FileTest and  
Fixnum at\_exit  
Float autoload  
FloatDomainError autoload?  
Forwardable begin  
GC binding  
Gem bindings  
Hash block\_given?  
IO break  
IOError callcc  
IRB caller  
IndexError case  
–More–Integer catch  
–More–Interrupt cb  
Kconv chomp  
Kernel chomp!  
LoadError chop  
LocalJumpError chop!  
Marshal chws  
MatchData class  
MatchingData clone  
Math conf  
Method context  
Module cws  
Mutex cwws  
NIL def  
NameError defined  
NilClass display  
NoMemoryError do  
NoMethodError dup  
NotImplementedError else  
Numeric elsif  
OCI8 end  
OCIBind ensure  
OCIBreak eql?  
OCIContinue equal?  
–More–\>\> d

> > ```
> > end
> > end
> > end
> > 
> > ```
> > 
> > end  
> > end  
> > SyntaxError: compile error  
> > (irb):182: syntax error  
> > (irb):183: syntax error  
> > (irb):184: syntax error  
> > (irb):190: syntax error  
> > from (irb):190  
> > from ?:0
> 
> >

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 15, 2006, 9:59pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/2 "2006-09-15T21:59:18Z")

</div>

On Sep 15, 2006, at 11:00 AM, Dave R. wrote:

> > > ```
> > > end
> > > if k.size>0
> > > k.first
> > > else
> > > 
> > > ```
> 
> ?\> #get defaults of kwd=0,kvar=700,kwh=1500  
> ?\> #else nil  
> ?\> case scat
> 
> > > ```
> > > when scat=='KWH' 1500
> > > 
> > > ```
> 
> Display all 459 possibilities? (y or n)

I can’t even tell what you are trying to do / write. It looks like  
“freak out” in your world means “respond with everything when I hit  
tab in a place without context” which is exactly what it should do.  
If not, I suggest turning off tab completion first and trying again.

But beyond that, I still can’t tell what you are trying to write. If  
it is something like:

case scat  
when scat == ‘KWH’ 1500  
scat==‘KVAR’ 700  
scat==‘KWD’ 0  
end

then yup. You’re going to get a syntax error as you did in your email  
and that has nothing to do with IRB. Try it just using ruby -c -e  
‘…code…’ for example to see. GIGO. See [http://www.zenspider.com/](http://www.zenspider.com/)  
Languages/Ruby/QuickRef.html#23 for examples of how to write properly  
formed case statements.

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 15, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/3 "2006-09-15T23:50:10Z")

</div>

Ken B. wrote:

> On Sat, 16 Sep 2006 04:58:12 +0900, Ryan D. wrote:
> 
> > > > > ```
> > > > > while r=cursor.fetch() and k.size<3
> > > > > end
> > > > > 
> > > > > ```
> > 
> > I can’t even tell what you are trying to do / write. It looks like  
> > “freak out” in your world means “respond with everything when I hit  
> > tab in a place without context” which is exactly what it should do.  
> > If not, I suggest turning off tab completion first and trying again.
> 
> yes,…\>\>\>\>How do you turn off tab completion in IRB?  
> …how do turn off the tab because that was the case (sort of speak)  
> i mean i use sciteK editor the comes with the one-click installer and i  
> guess i puts a tab in there somewhere but i don’t know how?

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 15, 2006, 11:31pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/4 "2006-09-15T23:31:28Z")

</div>

On Sat, 16 Sep 2006 04:58:12 +0900, Ryan D. wrote:

> > > > ```
> > > > while r=cursor.fetch() and k.size<3
> > > > end
> > > > 
> > > > ```
> 
> I can’t even tell what you are trying to do / write. It looks like  
> “freak out” in your world means “respond with everything when I hit  
> tab in a place without context” which is exactly what it should do.  
> If not, I suggest turning off tab completion first and trying again.

How do you turn off tab completion in IRB?

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 16, 2006, 5:01am UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/5 "2006-09-16T05:01:50Z")

</div>

in scite, just hit F5 to execute the app/script… no need to past to  
irb (assuming that’s what you’re doing

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 18, 2006, 6:17am UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/6 "2006-09-18T06:17:00Z")

</div>

On Sat, 16 Sep 2006 12:02:18 +0900, x1 wrote:

> > > > If not, I suggest turning off tab completion first and trying again.
> > > 
> > > yes,…\>\>\>\>How do you turn off tab completion in IRB?  
> > > …how do turn off the tab because that was the case (sort of speak)  
> > > i mean i use sciteK editor the comes with the one-click installer and i  
> > > guess i puts a tab in there somewhere but i don’t know how
> 
> in scite, just hit F5 to execute the app/script… no need to past to  
> irb (assuming that’s what you’re doing

I prefer my gvim and my xterm, thank you very much. How do I turn off  
tab  
completion in IRB?

–Ken

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 18, 2006, 6:53am UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/7 "2006-09-18T06:53:04Z")

</div>

> I prefer my gvim and my xterm, thank you very much. How do I turn  
> off tab  
> completion in IRB?

irb -f --readline #ignore .irbrc file and load readline w/o tab  
completion  
irb --noreadline #disable readline altogether

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 18, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/8 "2006-09-18T15:35:53Z")

</div>

On Mon, 18 Sep 2006 13:53:44 +0900, Reprisal wrote:

> > I prefer my gvim and my xterm, thank you very much. How do I turn  
> > off tab  
> > completion in IRB?
> 
> irb -f --readline #ignore .irbrc file and load readline w/o tab  
> completion  
> irb --noreadline #disable readline altogether

It seems that I don’t have a .irbrc, but I still have tab completion.  
I’d  
like to have readline support but no completion, but I don’t know what  
to  
put in my .irbrc (or .inputrc) to disable this.

–Ken

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 18, 2006, 10:21pm UTC](https://www.ruby-forum.com/t/irb-freaks-out-over-a-case-stmt/68833/9 "2006-09-18T22:21:03Z")

</div>

Ken B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It seems that I don’t have a .irbrc, but I still have tab completion. I’d  
> like to have readline support but no completion, but I don’t know what to  
> put in my .irbrc (or .inputrc) to disable this.

I figured it out. Somehow, at the end of  
/usr/lib/ruby/1.8/irb/completion.rb, I have the lines:

if Readline.respond\_to?(“basic\_word\_break\_characters=”)  
Readline.basic\_word\_break\_characters= " \t\n"\'`\>\<=;|&{("  
end  
Readline.completion\_append\_character = nil  
Readline.completion\_proc = IRB::InputCompletor::CompletionProc

So I just put code in my .irbrc to undo it:  
#disable completion, so that hitting tab just inserts a tab character  
Readline.completion\_append\_character = “”  
Readline.completion\_proc = lambda {|x| x+“\t”}

–Ken B.
