-
-
Save zpieslak/1292e720354b4524c330 to your computer and use it in GitHub Desktop.
DataStructure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataStructure | |
def initialize | |
@data = {} | |
@default = nil | |
end | |
def set(index, value) | |
@data[index] = value | |
end | |
def get(index) | |
value = @data[index] | |
value ? value : @default | |
end | |
def set_all(value) | |
@data = {} | |
@default = value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment