Method: Integer#chr

Defined in:
numeric.c

#chrString

Returns a string containing the ASCII character represented by the receiver's value.

65.chr    #=> "A"
?a.chr    #=> "a"
230.chr   #=> "\346"

Returns:


# File 'numeric.c'

/*
 *  call-seq:
 *     int.chr    => string
 *
 *  Returns a string containing the ASCII character represented by the
 *  receiver's value.
 *
 *     65.chr    #=> "A"
 *     ?a.chr    #=> "a"
 *     230.chr   #=> "\346"
 */

static VALUE
int_chr(num)
    VALUE num;
{
    char c;
    long i = NUM2LONG(num);

    if (i < 0 || 0xff < i)
    rb_raise(rb_eRangeError, "%ld out of char range", i);
    c = i;
    return rb_str_new(&c, 1);
}