Ruby/Statement/include

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск
м (1 версия: Импорт выборки материалов по Ruby)
 

Текущая версия на 18:00, 13 сентября 2010

include their code in other files with the Ruby include statement

#file: mathematics.rb.
module Mathematics
  def Mathematics.add(operand_one, operand_two)
    return operand_one + operand_two
  end
end
file: sentence.rb
module Sentence
  def Sentence.add(word_one, word_two)
    return word_one + "" + word_two
  end
end
file: ModuleTest.rb
include "mathematics.rb"
include "sentence.rb"
puts "2 + 3 = " + Mathematics.add(2, 3).to_s