Ruby - Enumerable - group_by

  • + 0 comments

    def group_by_marks(marks, pass_marks)

    data = marks.group_by { |_,mark| mark >= pass_marks}  
    result = {}
    result["Passed"] = data[true] unless data[true].nil?
    result["Failed"] = data[false] unless data[false].nil?
    result
    

    end