Skip to main content Link Search Menu Expand Document (external link)


truthy? Item state not UNDEF, not NULL and is not blank (‘’) when trimmed.puts "#{} is truthy" if item.truthy?
String methods* All methods for Ruby StringStringOne << StringOne + ' World!'
blank? True if state is UNDEF, NULL, string is empty or contains only whitespaceStringOne << StringTwo unless StringTwo.blank?
  • All String methods returns a copy of the current state as a string. Methods that modify a string in place, do not modify the underlying state string.


String operations can be performed directly on the StringItem

# StringOne has a current state of "Hello"
StringOne << StringOne + " World!"
# StringOne will eventually have a state of 'Hello World!'

# Add Number item to 5
NumberOne << 5 + NumberOne

String Items can be selected in an enumerable with grep.

# Get all StringItems
     .each { |string|"#{} is a String Item") }

String Item values can be matched against regular expressions

# Get all Strings that start with an H
        .each { |string|"#{} starts with an H") }