Ruby | String grapheme_clusters Method
Last Updated :
12 Dec, 2019
grapheme_clusters is a String class method in Ruby which is used to return an array of grapheme clusters in the given string.
Syntax: str.grapheme_clusters
Parameters: Here, str is the given string.
Returns: An array of grapheme clusters.
Example 1:
puts "Sample" .grapheme_clusters
puts "Program" .grapheme_clusters
|
Output:
S
a
m
p
l
e
P
r
o
g
r
a
m
Example 2:
puts "Ruby\n" .grapheme_clusters
puts "String" .grapheme_clusters
|
Output:
R
u
b
y
S
t
r
i
n
g
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...