summation of fields ruby filter

# Sample data structure
data = [
  { name: 'John', age: 25, salary: 50000 },
  { name: 'Jane', age: 30, salary: 60000 },
  { name: 'Bob', age: 28, salary: 55000 }
]

# Calculate the summation of the 'salary' field using Ruby filter
total_salary = data.inject(0) { |sum, hash| sum + hash[:salary] }

# Output the result
puts "Total Salary: #{total_salary}"