我有一个问题是为了更好地理解Ruby如何使用整数运算。
我有一段代码:
class Machine
@@users = {}
def initialize(username, password)
puts "username: #{username}"
puts "password: #{password}"
@username = username
@password = password
@@users[username] = password
@files = {}
end
def create(filename)
time = Time.now
@files[filename] = time
puts "#{filename} was created by #{@username} at #{time}."
end
def Machine.get_users
@@users
end
end
my_machine = Machine.new("eric", 01234)
put的输出如下:
username: eric
password: 668
如果密码值为零,那么为什么Ruby会更改密码的值?