[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:03042] Re: Problem with getc under UNIX with ruby 1.4.3

From: matz@... (Yukihiro Matsumoto)
Date: 2000-05-30 16:26:35 UTC
List: ruby-talk #3042
Hi,

In message "[ruby-talk:03040] Re: Problem with getc under UNIX with ruby 1.4.3"
    on 00/05/30, "David Douthitt" <DDouthitt@cuna.com> writes:

|#!/usr/bin/ruby
|
|class IO
|   def getc
|      begin
|        system("stty raw -echo")
|        str = self.getc
|      ensure
|        system("stty -raw echo")
|      end
|   end
|end
|
|str = STDIN.getc
|p str
|
|This code locks up - I think probably for semi-obvious reasons
|(self.getc IN getc) but I don't know how to call the "previous" getc
|from within a redefinition.  I tried super and it said there wasn't
|any.

Try `alias'.

   class IO
     alias orig_getc getc
     private :orig_getc
     def getc
       ...
       c = orig_getc
       ...
     end
   end

In This Thread

Prev Next