Skip to content

Instantly share code, notes, and snippets.

@vanakenm
Created January 16, 2015 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanakenm/2433a0fabf7846c55558 to your computer and use it in GitHub Desktop.
Save vanakenm/2433a0fabf7846c55558 to your computer and use it in GitHub Desktop.
Printing the students
students = [{name: "Laura", age: 10, enlisted: true},
{name: "Bob", age: 22},
{name: "Stephan", age: 18},
{name: "Lisa", age: 27, enlisted: true}]
def the_list(students)
students.map do |student|
enlisted = "* " if student[:enlisted]
"#{enlisted}#{student[:name]} #{student[:age]}"
end
end
p the_list(students)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment