Skip to content

Instantly share code, notes, and snippets.

@caioertai
Last active April 14, 2022 03:16
Show Gist options
  • Save caioertai/e0afbd13a2d3de6e0012f1de281df807 to your computer and use it in GitHub Desktop.
Save caioertai/e0afbd13a2d3de6e0012f1de281df807 to your computer and use it in GitHub Desktop.
# Declare an array literal
# Array CRUD
# Range
# ..
# ...
# Let's loop with the array
characters = ["Hank", "Sheila", "Bob"]
# for when given an array
# Let's loop with just the indexes
# 0 1 2 3
characters = ["Hank", "Sheila", "Bob", "Erik"]
# Let's print hi to all of them
# Hi, Hank! ... etc
# Print characters as a numbered list
# 1. Hank ... etc
characters = [
"Hank the Ranger",
"Sheila the Thief",
"Bob the Barbarian",
"Erik the Knight"
]
# Let's change our array to a new array:
# - upcased names
# - first names
characters = ["Diana", "Bob", "Dungeon Master", "Erik"]
# Let's count the names starting with D
characters = ["Hank", "Dungeon Master", "Bob", "Diana"]
# Select (filter) names starting with D
# Reject (filter out) names starting with D
# What_is_this?
method_name do |param|
"code goes here"
end
# And_this?
method_name { |param| "code goes here" }
# Let's write a benchmark tool using yield
## A method, with a block for the message, that can output the
## following from first and last name as args.
# Olá, <fully_sanitized_and_styled_person_name>. Como é que tu estás?
# Como estás, <fully_sanitized_and_styled_person_name>?
# Hey, <fully_sanitized_and_styled_person_name>, how are you?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment