Skip to content

Commit

Permalink
add yhara1: Worst abuse of constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mame committed Jun 1, 2013
1 parent a2eaaea commit 9f544ef
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 0 deletions.
File renamed without changes.
28 changes: 28 additions & 0 deletions yhara1/entry.rb
@@ -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 }
23 changes: 23 additions & 0 deletions yhara1/remarks.en.markdown
@@ -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.
24 changes: 24 additions & 0 deletions yhara1/remarks.markdown
@@ -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がエラーにならなくて、動きませんでした。
3 changes: 3 additions & 0 deletions yhara2/authors.markdown
@@ -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.

1 comment on commit 9f544ef

@yhara
Copy link

@yhara yhara commented on 9f544ef Jun 1, 2013

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 :-)

Please sign in to comment.