Skip to content
This repository was archived by the owner on May 23, 2020. It is now read-only.

Commit ddcb792

Browse files
more string operartions
1 parent 71d9cc8 commit ddcb792

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ _.capitalize_ capitalizes the first letter in the sentence and changes rest to l
4040
```ruby
4141
user_input.downcase!
4242
```
43+
_.include? "substring"_ checks if the variable has the substring. It returns boolean.
44+
```ruby
45+
if input.include? "hello"
46+
puts input
47+
end
48+
```
49+
*__Note__*: As a general rule, Ruby methods that end with ? evaluate to the boolean values true or false.
50+
51+
_.gsub_ stands global substitution. It substitutes a substring with another.
52+
```ruby
53+
user_input.gsub!(/s/,"th")
54+
```
55+
This replaces all 's' in the string to 'th'.
4356

4457
## Comments
4558
Single line comments are written with hash(#) in the start. Multi-line comments start with _=begin_ and end with _=end_ .

0 commit comments

Comments
 (0)