This file contains hidden or 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
#require 'Math' | |
class ArrayStatistic | |
def initialize(array) | |
@array = array | |
end | |
def largest | |
@array.sort[-1] | |
end |
This file contains hidden or 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
def deep_copy(obj) | |
# from: http://stackoverflow.com/a/8206537 | |
# serializes the object, then unserializes it to make a duplicate | |
return Marshal.load(Marshal.dump(obj)) | |
end |