Ruby
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 Greeter | |
def self.say_hi name | |
puts "Hi #{name}." | |
end | |
end | |
=begin | |
Output: | |
irb(main):007:0> Greeter.say_hi 'Ruby' | |
Hi Ruby. | |
=end |
Python
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 Greeter: | |
@staticmethod | |
def say_hi(name): | |
print ('Hi %s.') % name | |
#Output: | |
# Greeter.say_hi('Python') | |
# >> Hi Python. |
No comments:
Post a Comment