ascii ?c "c"[0] "c".ord.chr question

R

Ryan Davis

I was curious why the prefix ? for ascii code was removed in 1.9.x?

It wasn't removed, it just changed what it returns to work with =
multibyte chars:
multiruby -e 'p ?c'
=20
VERSION =3D 1.8.6-p399
CMD =3D ~/.multiruby/install/1.8.6-p399/bin/ruby -e p ?c
=20
99
=20
RESULT =3D 0
=20
VERSION =3D 1.8.7-p302
CMD =3D ~/.multiruby/install/1.8.7-p302/bin/ruby -e p ?c
=20
99
=20
RESULT =3D 0
=20
VERSION =3D 1.9.1-p129
CMD =3D ~/.multiruby/install/1.9.1-p129/bin/ruby -e p ?c
=20
"c"
=20
RESULT =3D 0
=20
VERSION =3D 1.9.2-p0
CMD =3D ~/.multiruby/install/1.9.2-p0/bin/ruby -e p ?c
=20
"c"
=20
RESULT =3D 0
=20
TOTAL RESULT =3D 0 failures out of 4
=20
Passed: 1.9.2-p0, 1.9.1-p129, 1.8.6-p399, 1.8.7-p302
Failed:=20

If you want compatibility between 1.8 and 1.9, I suggest the following:
505 % multiruby -e 'class String; def ord; self[0]; end unless =
"".respond_to? :eek:rd; end; p "c".ord'
=20
VERSION =3D 1.8.6-p399
CMD =3D ~/.multiruby/install/1.8.6-p399/bin/ruby -e 'class String; =
def ord; self[0]; end unless "".respond_to? :eek:rd; end; p "c".ord'
=20
99
=20
RESULT =3D 0
=20
VERSION =3D 1.8.7-p302
CMD =3D ~/.multiruby/install/1.8.7-p302/bin/ruby -e 'class String; =
def ord; self[0]; end unless "".respond_to? :eek:rd; end; p "c".ord'
=20
99
=20
RESULT =3D 0
=20
VERSION =3D 1.9.1-p129
CMD =3D ~/.multiruby/install/1.9.1-p129/bin/ruby -e 'class String; =
def ord; self[0]; end unless "".respond_to? :eek:rd; end; p "c".ord'
=20
99
=20
RESULT =3D 0
=20
VERSION =3D 1.9.2-p0
CMD =3D ~/.multiruby/install/1.9.2-p0/bin/ruby -e 'class String; =
def ord; self[0]; end unless "".respond_to? :eek:rd; end; p "c".ord'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top