String Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the use of ascii_only method?

A

Returns true for a string which has only ASCII characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is there any method called “b” in string?

A

yes.Returns a copied string whose encoding is ASCII-8BIT.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which methods returns an array of the Integer ordinals of the characters in string?

A

codepoints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where we can use “ord” method

A

to print integer ordinals of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

differentiate - “hex’ and “oct” methods

A

hex - Treats leading characters from str as a string of hexadecimal digits

oct-Treats leading characters of str as a string of octal digits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which method searches pattern (regexp) in the string and returns the part before it, the match, and the part after it.?

A

Partition method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to remove invalid byte sequence in a string?

A

scrub method

“abc\u3042\x81”.scrub(“”) #=> “abc\u3042

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

a = “ 3”
How you will get this string?(no concatenation)

“Ruby 3”

A

a.prepend(“Ruby”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which methods returns a new string where runs of the same character that occur in this set are replaced by a single character?

A

squeeze

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the use of “to_c” method in String?

A

Returns a complex which denotes the string form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly