Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

×Ô¶¯»¯²âÊÔ֮·£¨Èý£© rubyÀïµÄgetÓëset·½·¨

ÕÕÀý¿ÉÒÔÏÈ¿´¶Ë³ÌÐò
class Person
 
  def initialize( name,age=18 )
    @name = name
    @age = age
    @motherland = "China"
  end
 
  def talk
    puts "my name is "+@name+", age is "+@age.to_s
    if  @motherland == "China"
      puts "I\'m Chinese."
    else
      puts "I\'m foreigner."
    end
  end
 
  attr_writer :motherland
 
end
p1=Person.new("kaichuan",20)
p1.talk
p2=Person.new("Ben")
p2.motherland="ABC"
p2.talk
³ÌÐòÔËÐнá¹û
 my name is kaichuan, age is 20
I'm Chinese.
my name is Ben, age is 18
I'm foreigner.
>Exit code: 0
ÓйýÃæÏò¶ÔÏó±à³ÌÓïÑÔ¾­ÀúµÄͯЬºÜÈÝÒ׿ÉÒÔ¿´Ã÷°×£¬µ«ÊÇÀïÃæÖµµÄÒ»ÌáµÄÊÇÕâ¾ä£º“attr_writer :motherland”
Õâ¾ä»°Ï൱ÓÚÎÒÃÇÃæÏò¶ÔÏó±à³ÌÓïÑÔµÄset·½·¨£¬Ò²¿ÉÒÔÕâÑùд
def motherland=(value)
   return @motherland =value
end
ÄÇôÏàÓ¦µÄget·½·¨Îª attr_ reader :motherland
Ï൱ÓÚ
def motherland
  return @motherland
end
ÏàÓ¦µÄ attr_accessor :motherland Ï൱ÓÚattr_reader:motherland£» attr_writer :motherland


Ïà¹ØÎĵµ£º

ruby c++

While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......

Ruby on Rails°²×°ÓëÅäÖÃ

Ò»£¬Ruby°²×°£º
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
¹Ù·½ÍøÕ¾ÏÂÔØruby186-26(for windows)£¬Ä¬Èϰ²×°ruby£»
·¾¶c:\ruby
¶þ£¬railsÏÂÔØ°²×°£º
http://rubyforge.org/frs/download.php/29361/rails-2.0.2.zip
ÏÂÔØrails2.0.2.zip£¬½«ÆäcopyÖÁruby°²×°Â·¾¶£¬²¢¸ÄÃûΪrails.zip£»
³¢ÊÔ²»½âÑ¹Ö ......

rails on ruby exmaples depot

1.install ruby
    download from http://www.ruby-lang.org/en/news/2009/12/07/ruby-1-9-1-p376-is-released/
2.install rails
   ruby gem install rails --include-dependencies
3.install mysql
   download from http://sourceforge.net
   ruby gem install&nb ......

Ruby ShoesµÄСÎÊÌâ

½ñÌì°ÑRuby Shoes´ò°üµÄ³ÌÐò¸´ÖƵ½Ã»Óа²×°Ruby ShoesµÄ»úÆ÷ÉÏ£¬·¢ÏÖËü»¹Ï²»ÁËRuby ShoesµÄ»·¾³°ü¡£
ÕâÈÃÎҸоõºÜ¾ÚÉ¥£¬ºÃ²»ÈÝÒ×ÈëÃÅÁËÒ»ÃÅÓïÑÔ£¬È´ÓöÉÏÁËÎÞ·¨²¿ÊðµÄÎÊÌâ¡£
ÉõÖÁ£¬ÎÒºóÀ´ÏëÒª°ÑÔËÐл·¾³Ç¶Èëµ½Ruby ShoesÖУ¬¶¼Ã»Äܹ»×öµ½¡£
ÕâÑùµÄÎÊÌâÕæÊÇÈÃÎҸоõµ½¶ÔShoesµÄʧÍû¡£
²»¹ý»¹ºÃ£¬³öÁËRuby Shoes£¬»¹Óкܶ ......

×Ô¶¯»¯²âÊÔ֮·£¨Ò»£© ruby³õ̽

´Ó½ñÌìÆð²»ÔÙÀË·Ñʱ¼ä£¬¿ªÊ¼×ßÏò×Ô¶¯»¯²âÊÔÕâÌõ¹âÃ÷µÄµÀ·£¬²¢ÒԴһ¸ö×Ô¶¯»¯²âÊÔÆ½Ì¨ÎªÄ¿±ê£¬²¢Õâ¸ö¹ý³ÌÒ»µãµãµÄ¼Ç¼ÏÂÀ´ºÍ´ó¼Ò·ÖÏí
Ê×ÏÈ£¬ÊÇruby»·¾³µÄ´î½¨
£¨1£©µ½rubyµÄ¹ÙÍø£ºhttp://www.ruby-lang.org/en/ÏÂÔØ ruby°²×°³ÌÐò;
      PS £ºÑ¡Ôñ ruby on windows,ÎÒÏÂÔØµÄÊÇRuby 1.8.6 One ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ