Created
March 9, 2011 22:32
-
-
Save undecided/863152 to your computer and use it in GitHub Desktop.
Shows a simple class implemented in Ruby and Mirah
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
# Ruby | |
class Rubyish | |
def a_method(some_string, some_hash) | |
@message = some_string | |
@transform = some_hash | |
puts @message | |
end | |
def another_method | |
@transform.each_pair do |key, val| | |
puts @message.gsub(key.to_s, val.to_s) | |
end | |
end | |
end | |
@a = Rubyish.new | |
@a.a_method("This looks like ruby", :looks => :smells) | |
@a.another_method | |
# Mirah | |
import java.util.HashMap | |
class Rubyish | |
def a_method(some_string:String, some_hash:HashMap) | |
@message = some_string | |
@transform = some_hash | |
puts @message | |
end | |
def another_method | |
@transform.keys.each do |key| # maps down to java's keySet | |
puts @message.replaceAll(String(key), String(@transform[key])) | |
end | |
end | |
end | |
@a = Rubyish.new | |
@a.a_method("This looks like ruby", :looks => :smells) | |
@a.another_method | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment