Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3223

Re: assert_name doesn't exist as a function?

From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: assert_name doesn't exist as a function?
Date 2011-04-20 03:45 -0500
Organization Service de news de lacave.net
Message-ID <b89f11d980aec36ad86a4dcd486ea65f@ruby-forum.com> (permalink)
References <0b400c83ed884b0303d1f4a910bbf476@ruby-forum.com> <c79c57b7f70e1e4c454e3d5af63f8c26@ruby-forum.com>

Show all headers | View raw


Mike RegistrationErr wrote in post #993884:
> I added this line:
> require 'test/unit/assertions'
>
> Which is different from:
> include Test::Unit::Assertions
>
> In PHP require and include are the same hence the confusion having come
> from PHP. I don't understand the difference between require and include
> in ruby yet, but at least my problem is sorted :)

"require" means "go and load this ruby source file, if you've not loaded 
it before"

"include" means (roughly) "add the methods in that module into the 
current class"

"extend" means (roughly) "add the methods in that module into the 
current object"

module Foo
  def bar
    puts "I am bar!"
  end
end

bar         # doesn't work
include Foo
bar         # now it works

a = "Hello"
a.extend Foo
a.bar       # this works too

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

assert_name doesn't exist as a function? Mike RegistrationErr <xandrani@gmail.com> - 2011-04-19 20:04 -0500
  Re: assert_name doesn't exist as a function? Mike RegistrationErr <xandrani@gmail.com> - 2011-04-19 20:15 -0500
    Re: assert_name doesn't exist as a function? Brian Candler <b.candler@pobox.com> - 2011-04-20 03:45 -0500
  Re: assert_name doesn't exist as a function? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-20 12:21 -0500
    Re: assert_name doesn't exist as a function? Brian Candler <b.candler@pobox.com> - 2011-04-20 15:38 -0500

csiph-web