• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

例外で反応するのをrespondしてるといわないでほしい・・・

ruby>>
irb(main):001:0> 1.respond_to? :dup
=> true
irb(main):002:0> 1.dup
TypeError: can't dup Fixnum
from (irb):2:in `dup'
from (irb):2
from :0
<<ruby

posted by technohippy technohippy on Thu 7 Aug 2008 at 16:46 with 0 comments

考えてみりゃそりゃそうなんだけど、

ruby>>
irb(main):001:0> true && nil
=> nil
irb(main):002:0> true && false
=> false
<<ruby

必ず真偽値を返す演算子があってもいいのにと思った

posted by technohippy technohippy on Thu 7 Aug 2008 at 12:47 with 2 comments

モジュール内で、関係ないモジュールのクラスを定義してもいいんですね。
まぁ、やらん方がいいとは思うけど。

ruby>>
module Foo
end

module Baz
class ::Foo::Bar
def xyzzy
'hoge'
end
end
end

Foo::Bar.new.xyzzy #=> 'hoge'
<<ruby

posted by technohippy technohippy on Tue 5 Aug 2008 at 20:40 with 0 comments

なんでClass#superclassはあるのに#subclassesはないんだろう?

ruby>>
class Class
def subclasses
ret = []
ObjectSpace.each_object(Class) do |cls|
ret << cls if cls.superclass == self
end
ret
end
end
<<ruby

posted by technohippy technohippy on Mon 4 Aug 2008 at 01:40 with 5 comments
右下のTouch Me!ガジェットは共有設定にしてみたんだけど他の人でも使えるんだろうか?設定画面に見えるようなら皆さんも是非どうぞ。
posted by technohippy technohippy on Wed 30 Jul 2008 at 19:25 with 3 comments

Web creators9月号の中澤さんの記事でKaoChartを紹介してもらったのでみんな見て見てー。
半年以上放置してるサービスなのにありがたいっす。

posted by technohippy technohippy on Wed 30 Jul 2008 at 15:12 with 0 comments