I am trying to understand the code written below. What does a colon after the parameter in the initialize method mean? like consumable: account: etc. I understand having a colon before the variable name means it is a symbol and cannot change its value unlike variables. But what does having a colon after mean? Thanks
class Purchaser
attr_accessor :consumable, :account, :amount, :reason
def initialize(consumable:, account:, amount:, reason:)
@consumable = consumable
@account = account
@amount = amount
@reason = reason
end
def make_purchase
if purchase.update(account: account, amount: amount, reason: reason) && decrease_stock
return true
else
return false
end