-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.rb
More file actions
16 lines (14 loc) · 756 Bytes
/
Copy pathvariable.rb
File metadata and controls
16 lines (14 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Variable
# In Ruby, a variable is a container that holds a value. You can assign a value to a variable using the `=` operator.
# Variables in Ruby are dynamically typed, which means you can change the type of value they hold at any time.
# Example of variable assignment
name = "Luthfi"
age = 25
is_student = true
country = "Indonesia"
# There is concept called string interpolation in Ruby, which allows you to embed variables directly within a string.
# To use string interpolation, you need to wrap the variable in `#{}` within a double-quoted string.
puts "Name: #{name}" # Output: Name: Luthfi
puts "Age: #{age}" # Output: Age: 25
puts "Is Student: #{is_student}" # Output: Is Student: true
puts "Country: #{country}" # Output: Country: Indonesia