Advertisement
Raventor

initialize method

Dec 23rd, 2020
1,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.24 KB | None | 0 0
  1. class Account
  2.   attr_reader :name, :balance
  3.  
  4.   def initialize(name, balance = 100)
  5.     @name = name
  6.     @balance = balance
  7.  
  8.     puts pin
  9.   end
  10.  
  11.   private
  12.  
  13.   def pin
  14.     @pin = 1234
  15.   end
  16. end
  17.  
  18. $account = Account.new('Attila', '200')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement