• 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してるといわないでほしい・・・

   1  irb(main):001:0> 1.respond_to? :dup
   2  => true
   3  irb(main):002:0> 1.dup
   4  TypeError: can't dup Fixnum
   5          from (irb):2:in `dup'
   6          from (irb):2
   7          from :0

posted by Png technohippy on Thu 7 Aug 2008 at 16:47

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

   1  irb(main):001:0> true && nil
   2  => nil
   3  irb(main):002:0> true && false
   4  => false

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

posted by Png technohippy on Thu 7 Aug 2008 at 12:52 with 2 comments
5th Tue

クラス定義

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

   1  module Foo
   2  end
   3  
   4  module Baz
   5    class ::Foo::Bar
   6      def xyzzy
   7        'hoge'
   8      end
   9    end
  10  end
  11  
  12  Foo::Bar.new.xyzzy #=> 'hoge'

posted by Png technohippy on Tue 5 Aug 2008 at 20:43

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

   1  class Class
   2    def subclasses
   3      ret = []
   4      ObjectSpace.each_object(Class) do |cls|
   5        ret << cls if cls.superclass == self
   6      end
   7      ret
   8    end
   9  end

posted by Png technohippy on Mon 4 Aug 2008 at 01:42 with 5 comments
30th Wed

そういえば

右下のTouch Me!ガジェットは共有設定にしてみたんだけど他の人でも使えるんだろうか?設定画面に見えるようなら皆さんも是非どうぞ。

posted by Png technohippy on Wed 30 Jul 2008 at 19:24 with 3 comments

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

posted by Png technohippy on Wed 30 Jul 2008 at 14:59