Skip to content

Instantly share code, notes, and snippets.

@glurp
Created December 20, 2018 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glurp/dd77b301c5b8e0bec29c1ea51c87c8e5 to your computer and use it in GitHub Desktop.
Save glurp/dd77b301c5b8e0bec29c1ea51c87c8e5 to your computer and use it in GitHub Desktop.
execute and print ruby instructions
str=<<'EEOF'
"a,b,c,d".split(/,/)
"a,bb,c".scan(/\w+/)
[1,2,3].inspect
[1,2,3].join(",")
Hash[1,2,3,4]
h=[1,2,3,4,5,6,7,8].group_by {|v| v%4}
h.to_a()
h.keys()
h.values()
EEOF
h=nil
str.lines.each {|l|l.strip!; print "Eval of #{l} \t: "; p eval(l) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment