Created
February 28, 2022 16:57
-
-
Save dpritchett/74156d21a02b43972a70c7f1405c8b6f to your computer and use it in GitHub Desktop.
This file contains 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
[5] pry(main)> def fname_matches?(person, match_this) | |
[5] pry(main)* person[:fname] == match_this | |
[5] pry(main)* end | |
=> :fname_matches? | |
[6] pry(main)> people = [{ fname: 'daniel', lname: 'pritchett' }, { fname: 'alice', lname: 'jones' }] | |
=> [{:fname=>"daniel", :lname=>"pritchett"}, {:fname=>"alice", :lname=>"jones"}] | |
[7] pry(main)> people.select { |person| fname_matches?(person, 'daniel') } | |
=> [{:fname=>"daniel", :lname=>"pritchett"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment