Skip to content

Commit

Permalink
exercises updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bpurinton committed Feb 8, 2023
1 parent 627bfde commit 56dcf8a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
4 changes: 0 additions & 4 deletions dig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
}


#### SOLUTION:

# p sample_hash.fetch(:class).fetch(:student).fetch("marks").fetch("history")


# ~~~~~ Specs (make it do these things) ~~~~~
#
Expand Down
2 changes: 1 addition & 1 deletion person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Maude 24 Artist
# { :name => "Maude", :age => 24, :occupation => "Artist" }
#
# Make sure the value of the :age key is an Integer
# Hint: Make sure the value of the :age key is an Integer

p "Enter a name, age, and occupation separated by spaces:"

Expand Down
37 changes: 37 additions & 0 deletions solutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Solutions

## dig.rb

```ruby
p sample_hash.fetch(:class).fetch(:student).fetch("marks").fetch("history")
```

## find_values.rb

```ruby
integer = gets.chomp.to_i

if sample_hash.key(integer) == nil
p "Could not find the integer #{integer}"
else
p "#{integer} is under the key: #{sample_hash.key(integer)}"
end
```

## list.rb

```ruby
list_of_people.each do |person_hash|
if person_hash.fetch(:age) >= 16
p person_hash.fetch(:name)
end
end
```

## person.rb

```ruby
user_input = gets.chomp.split
user_hash = { :name => user_input.at(0), :age => user_input.at(1).to_i, :occupation => user_input.at(2) }
p user_hash
```

0 comments on commit 56dcf8a

Please sign in to comment.