Skip to content

Instantly share code, notes, and snippets.

@bdthinh
Last active December 21, 2015 19:39
Show Gist options
  • Save bdthinh/6355515 to your computer and use it in GitHub Desktop.
Save bdthinh/6355515 to your computer and use it in GitHub Desktop.
def method
def method_name(x1,x2,x3,x4)
def method_name(name,mode ='r')
def method_name(options)
def method_name(*points)
def story2(options={})
options = { person: "Yankee Doodle", animal: "Tiger" }.merge(options)
"#{options[:person]} went to town, riding on a #{options[:animal]}"
end
def distance4(*points)
x1,y1,x2,y2 = points.flatten
raise ArgumentError unless [x1,y1,x2,y2].all? { |e| Numeric === e }
Math.hypot(x2 - x1, y2 - y1)
end
"This is a string".instance_eval do
"O hai, can has reverse? #{reverse}. kthxbye"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment