"Simon Strandgaard" <neoneye / adslhome.dk> schrieb im Newsbeitrag
news:20040520180647.57559b82.neoneye / adslhome.dk...
>
> Solved, just discovered that #dup clones, but without
> cloning the position.  Shouldn't #dup clone the file position,
> rather than leaving it as garbage ?

Probably.  OTOH hand I view file positions as tentative: you have to re-seek
anyway if you want to change from reading to writing or vice versa and in
some other situations I believe.

    robert

> server> ruby a.rb
> 5
> 199           # <<<<<  GARBAGE when using #dup
> 10
> 5
> server> cat a.rb
> f1 = File.open(__FILE__, 'r')
> f1.seek(5)
> p f1.pos  # -> 5
> #f2 = f1.clone.reopen(f1)
> f2 = f1.dup
> p f2.pos  # ugly -> 5,  dup -> garbage
> f2.seek(10)
> p f2.pos  # -> 10
> # check harmless
> p f1.pos  # -> 5
> server>
>
>
> maybe I should make an RCR about this issue ?
>
> -- 
> Simon Strandgaard
>
>