[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dennou-ruby:001199] Re: [ANN] RubyDCL 1.1.0



At Mon, 20 May 2002 15:14:21 +0900,
Takeshi Horinouchi wrote:

> ���ꥢ����ͭ���ǤϤʤ��Τ������Ȥ��Ƥ⡢udcntr ����Ǥ����Ƥ��
> ���ʤ���Τ� module_function �ˤ��Ƥʤ��Ȥʤ�ʤ��ä�Ǽ��������
> �ʤ���__udcntr �ϥץ饤�١��Ȥʥ᥽�åɤˤ�����������ɡ��ɤ���
> ������������..��

�Ȥꤢ�������������ΤϤɤ��Ǥ��礦?

  class Module
    def module_function_subroutine(*arg)
      arg.each do |s|
        module_function s
        private_class_method s
      end
    end
  end

  module Test
    def hello
      p hello_str
    end

    module_function(:hello)

    def hello_str
      "HELLO"
    end

    module_function_subroutine(:hello_str)

  end

  begin
    Test.hello     #=> "HELLO"
    Test.hello_str
  rescue Exception
    p $!  #<NoMethodError: private method `hello_str' called for Test:Module>
  end

-- Gotoken