Created
May 24, 2013 01:28
-
-
Save hfm/5640727 to your computer and use it in GitHub Desktop.
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
| def string_shuffle(s) | |
| s.split('').shuffle.join | |
| end | |
| p string_shuffle("foobar") |
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 String | |
| def shuffle | |
| self.split('').shuffle.join | |
| end | |
| end | |
| p "foobar".shuffle |
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
| 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 |
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
| # 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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4_6_3.rbは https://gist.github.com/kitak/5640738 が良さそう。