grapheme_clusters is a String class method in Ruby which is used to return an array of grapheme clusters in the given string.
Ruby
Output:
Ruby
Output:
Syntax: str.grapheme_clusters Parameters: Here, str is the given string. Returns: An array of grapheme clusters.Example 1:
# Ruby program to demonstrate
# the grapheme_clusters method
# Taking a string and
# using the method
puts "Sample".grapheme_clusters
puts "Program".grapheme_clusters
S a m p l e P r o g r a mExample 2:
# Ruby program to demonstrate
# the grapheme_clusters method
# Taking a string and
# using the method
puts "Ruby\n".grapheme_clusters
puts "String".grapheme_clusters
R u b y S t r i n g