Skip to content

Instantly share code, notes, and snippets.

@hfm
Created May 24, 2013 01:28
Show Gist options
  • Select an option

  • Save hfm/5640727 to your computer and use it in GitHub Desktop.

Select an option

Save hfm/5640727 to your computer and use it in GitHub Desktop.
def string_shuffle(s)
s.split('').shuffle.join
end
p string_shuffle("foobar")
class String
def shuffle
self.split('').shuffle.join
end
end
p "foobar".shuffle
params = Hash.new
params[:father] = Hash.new
params[:father][:first] = "Takahiro"
params[:father][:last] = "Okumura"
params[:mother] = Hash.new
params[:mother][:first] = "Haha"
params[:mother][:last] = "Okumura"
params[:child] = Hash.new
params[:child][:first] = "Chichi"
params[:child][:last] = "Okumura"
p params
# Hash-merge
# http://ruby-doc.org/core-2.0/Hash.html#method-i-merge
params1 = {name: "Takahiro Okumura", email: "hfm@paperboy.co.jp"}
params2 = {job: "Engineer"}
p params1.merge(params2)
p params2.merge(params1)
@hfm

hfm commented May 24, 2013

Copy link
Copy Markdown
Author

4_6_3.rbは https://gist.github.com/kitak/5640738 が良さそう。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment