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
""" | |
# Your order, please | |
# | |
# Sort a given string. Each word in the String will contain a single number. This number is the position the | |
# word should have in the result. | |
# | |
# Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). | |
# | |
# If the input String is empty, return an empty String. The words in the input String will only contain valid | |
# consecutive numbers. |
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
class Car | |
attr_reader :mileage | |
def initialize | |
@mileage = 0 | |
end | |
def drive | |
update_mileage | |
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
class Toyota < Car | |
def self.name | |
"Toyota #{superclass}" | |
end | |
end | |
# => Toyota.name | |
# "Toyota Car" |
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
class Car | |
attr_reader :mileage | |
def initialize | |
@mileage = 0 | |
end | |
def drive | |
update_mileage | |
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
class Toyota < Car | |
class << self | |
def name | |
"Toyota #{superclass}" | |
end | |
end | |
end | |
# => Toyota.name | |
# "Toyota Car" |
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
class Toyota < Car | |
def self.name | |
self.i_am | |
end | |
private | |
def self.i_am | |
"Toyota #{superclass}" | |
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
class Toyota < Car | |
class << self | |
def name | |
i_am | |
end | |
private | |
def i_am | |
"Toyota #{superclass}" |
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
class Toyota < Car | |
def self.name | |
self.i_am | |
end | |
private_class_method def self.i_am | |
"Toyota #{superclass}" | |
end | |
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
class Toyota < Car | |
def self.name | |
self.i_am | |
end | |
def self.i_am | |
"Toyota #{superclass}" | |
end | |
def self.do_something |
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
function getDateString() { | |
let dateString; | |
// ... | |
// processing that sometimes resulted | |
// in dateString evaluating to undefined | |
return dateString; | |
} | |
const dateString = getDateString(); | |
moment(dateString); |
OlderNewer