Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add yhara1: Worst abuse of constants
- Loading branch information
Showing
9 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
def _(&b)$><<->(x){x ? (String===x ?x.upcase: | ||
(Class===x ? x : x.class).name[$a?0:($a=5)]): | ||
" "}[ begin b[];rescue Exception;$!;end ] end | ||
|
||
_ { return } | ||
_ { method(:p).unbind } | ||
_ { eval "{ " } | ||
_ { Thread.current.join } | ||
_ { nil } | ||
_ { select } | ||
_ { ruby } | ||
_ { self.class } | ||
_ { Thread.current.group } | ||
_ { nil.to_h } | ||
_ { "\xFF".encode("big5") } | ||
_ { raise } | ||
_ { [0][1] } | ||
_ { Regexp.compile "*" } | ||
_ { RUBY_COPYRIGHT[32] } | ||
_ { binding } | ||
_ { :s.class.name[1] } | ||
_ { warn } | ||
_ { [a: :b][0] } | ||
_ { methods } | ||
_ { IO.class } | ||
_ { {}.fetch(0) } | ||
_ { open " " } | ||
_ { 1000000.chr } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
### Remarks | ||
|
||
Just run it with no argument: | ||
|
||
ruby entry.rb | ||
|
||
I confirmed the following implementations/platforms: | ||
|
||
* ruby 2.0.0p0 (2013-02-24 revision 39474) [x86\_64-darwin12.2.1] | ||
|
||
### Description | ||
|
||
It prints JUST ANOTHER RUBY HACKER¡£ | ||
|
||
### Internals | ||
|
||
This script uses characters in constants in Object class. It | ||
intentionally raises some exceptions. The second 'U' comes from | ||
RUBY\_COPYRIGHT, "Yukihiro Matsumoto". | ||
|
||
### Limitation | ||
|
||
This program does not work on JRuby because "return" does not raise an exception. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
### Remarks | ||
|
||
引数なしで普通に実行してください。 | ||
|
||
ruby entry.rb | ||
|
||
以下の実装・プラットフォームで動作確認しています。 | ||
|
||
* ruby 2.0.0p0 (2013-02-24 revision 39474) [x86\_64-darwin12.2.1] | ||
|
||
### Description | ||
|
||
JUST ANOTHER RUBY HACKERと表示します。 | ||
|
||
### Internals | ||
|
||
Objectクラスの定数から文字を拾っています。 | ||
そのために、意図的に例外を起こしています。 | ||
「U」が一つしか見つからなかったので、もう一個はRUBY\_COPYRIGHTの | ||
「Yukihiro Matsumoto」から取っています。 | ||
|
||
### Limitation | ||
|
||
JRubyはreturnがエラーにならなくて、動きませんでした。 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Yutaka Hara | ||
* yutaka.hara.gmail.com | ||
* cctld: jp |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9f544ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention that, some ways of raising "desired" exception is taken form Japanese Ruby Doc.
eg: http://doc.ruby-lang.org/ja/2.0.0/class/RangeError.html
Thank you Rurema (and maybe rdoc) writers :-)