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
class FizzBuzz | |
def initialize( from = 1, to = 30 ) | |
@from, @to = [ from, to ].minmax | |
block_given? ? yield( self ) : self | |
end | |
def spec( out, &cond ) | |
( @specs ||= [] ) << lambda { |e| cond[ e ] ? out : nil } | |
end |
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
# String#bytes.to_aよりもString#unpack("C*") |
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
# 定数参照 | |
### ・クラス/モジュールで定義された定数は、その定数が定義されたクラス/モジュールに格納される | |
### ・クラス/モジュール定義の外(トップレベル)で定義された定数は Object に格納される | |
### ・メソッドの中では定義できません | |
## ネスト | |
### ・定数はその定数が定義されたクラス/モジュール定義の中(メソッドやネストしたクラス/モジュールも含む)から参照できる | |
CONST = "TOP" | |
module A | |
CONST = "A" | |
end |
NewerOlder