June 2017
Beginner
330 pages
7h 30m
English
The following is an example for the LSP:
require 'date'class User attr_accessor :settings, :email def initialize(email:) @email = email endendclass AdminUser < Userenduser = User.new(email: "user@test.com")user.settings = { level: "Low Security", status: "Live", signed_in: Date.today}admin = AdminUser.new(email: "admin@test.com")admin.settings = ["Editor", "VIP", Date.today]puts user.settingsputs admin.settings
For our code walk-through, I created a basic User class in Ruby. Additionally, I built an AdminUser class that inherits from the parent User class. The classes have attributes for settings and an email.
In our case study, we decided to make an interesting decision to use the hash data type for our settings in the ...
Read now
Unlock full access