mention the String#[] differences in 1.8 and 1.9, show example workaround
git-svn-id: file:///home/svn/framework3/trunk@9620 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
63a563c20b
commit
1b8c84d40a
8
HACKING
8
HACKING
|
@ -45,6 +45,14 @@ using IO#binmode). This not only helps keep Windows and non-Windows
|
|||
runtime environments consistent with each other, but also guarantees
|
||||
that files will be treated as ASCII-8BIT instead of UTF-8.
|
||||
|
||||
5. Don't use String#[] for a single character. This returns a Fixnum in
|
||||
ruby 1.8 and a String in 1.9, so it's safer to use the following idiom:
|
||||
str[idx,1]
|
||||
which always returns a String. If you need the ASCII byte, unpack it like
|
||||
so:
|
||||
str[idx,1].unpack("C")
|
||||
|
||||
|
||||
Creating New Modules
|
||||
====================
|
||||
|
||||
|
|
Loading…
Reference in New Issue