Project

General

Profile

Actions

Bug #6489

closed

A File instance changes its class to IO

Added by yimutang (Joey Zhou) almost 12 years ago. Updated almost 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
Backport:
[ruby-core:45213]

Description

I don't know whether it is a bug, or a feature.

1.9.3p194 :001 > f = open('xxx','w')
=> #File:xxx
1.9.3p194 :002 > f.class
=> File
1.9.3p194 :003 > f.id
=> 80452110
1.9.3p194 :004 > f.reopen(STDOUT)
=> #<IO:>
1.9.3p194 :005 > f.class
=> IO
1.9.3p194 :006 > f.id
=> 80452110

You see, an object(id:80452110) changes its class from File to IO.
Is it ok?

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

  • Status changed from Open to Rejected

OK.

Updated by mame (Yusuke Endoh) almost 12 years ago

Hello,

2012/5/24 yimutang (Joey Zhou)

You see, an object(id:80452110) changes its class from File to IO.
Is it ok?

FYI: The rdoc of IO#reopen says:

  • call-seq:
  • ios.reopen(other_IO)         -> ios
    
  • ios.reopen(path, mode_str)   -> ios
    
  • Reassociates ios with the I/O stream given in
  • other_IO or to a new stream opened on path. This may
  • dynamically change the actual class of this stream.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0