I want to make a method named default_classroom. so that it takes an array of keys and a default value and returns a hash with all keys set to the default value. (Like, all students go to the same classroom. Here, students are the keys and class as a default value)
def default_classroom(students, default_class)
end
puts default_classroom([:jony, :marry], 8)
# should return => {jony: 8, marry: 8}
i did this:
def default_classroom(students, default_class)
Hash[ students, default_class]
end
and also this:
def default_classroom(students, default_class)
Hash[*students.flatten(default_class)]
end
but still not working. Will you please advice me, How can i complete that?