Last active
February 18, 2024 04:18
-
-
Save nwalberts/aa8285b345c66c268315abc5319cce2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Data Types | |
# String | |
name = "Nick" | |
"I am a dude named Nick" | |
"$&fp10/" | |
# Integer | |
age = 24 | |
5729 | |
# Boolean | |
isAdult = true | |
false | |
# Array | |
[18, 78, 34, 47, 26] | |
names = ["Nick", "Brianna", "Nader"] | |
# Hash | |
my_address = { street_name: "Raymond", number: 33, street_type: "Lane" } | |
## ----- | |
# Variables | |
my_name = "Nick Alberts" | |
# Conditionals | |
# if your name is Nick, say HOWDY | |
# otherwise, just say hello | |
if my_name == "Nick Alberts" | |
puts "Howdy there, Nick!" | |
else | |
puts "Hello there" | |
# puts "Hello there" + my_name | |
end | |
# Looping | |
names = ["Jenna", "Brianna", "Nader"] | |
names.each do |name| | |
puts "Hello " + name | |
end | |
# "Jenna" | |
# "Brianna" | |
# "Nader" | |
# Methods | |
names = ["Jenna", "Brianna", "Nader"] | |
randomFriends = ["Jackie", "Rachel", "Ohad"] | |
def sayHelloToFriends(listOfNames) | |
listOfNames.each do |name| | |
puts "Hello " + name | |
end | |
end | |
sayHelloToFriends(randomFriends) | |
sayHelloToFriends(names) | |
# "Jenna" | |
# "Brianna" | |
# "Nader" | |
# "Jackie" | |
# Rachel | |
# Ohad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment