Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 on Rails°²×°²½Öè


±¾ÎĽéÉÜÁËRuby on RailsµÄÏêϸ°²×°²½Öè¡£ÎÄÖÐʹÓõÄRuby on Rails°æ±¾ÊÇ1.8.6-26¡£°²×°RubyÖ®ºó°²×°Rails£¬È»ºó¾Í¿ÉÒÔ´´½¨WebÓ¦Ó㬲¢ÔÚ±¾µØ²âÊÔÁË¡£
1¡¢°²×°ruby
²»ÓÃ˵ ÊÇÏÂÔØ°²×°°ü£ºhttp://rubyforge.org/frs/?group_id=167£¬×¢Òâ°æ±¾---º¦È˲»Ç³£¬ºóÃæ»á˵µ½£¬ÎÒϵÄÊÇ1.8.6-26
×°Íêºó£¬¿ÉÒÔÓÃruby -v ²âÊÔÊÇ·ñ° ......

ruby on rails(10) ´¦Àí¶©µ¥

¶©µ¥´¦Öã¬Ê×ÏÈÒªÓÐÒ»¸ö¶©µ¥µÄÏêϸÁÐ±í£¨°üÀ¨ÊýÁ¿£¬¼ÛǮɶµÄ£©ºÍÒ»¸ö¶ÔÓÚ¸öÈ˵ÄһЩÐÅÏ¢µÄÒ»¸ö±í¡£Òò¶øÎÒÃÇ´´ÔìÁ½¸öÄ£ÐÍ£¬line_item(ÁбíÏî),order(Áбí)£¬Æäºó±àÕßÈç´Î
/db/migrate xxx_create_order xxx_line_item
Ruby´úÂë
Ò».class CreateOrders < ActiveRecord::Migration
¶þ.def self.up
3. create_tabl ......

C++0x³¢ÏÊ ÓÃlambda±í´ïʽģÄâRubyµÄ¹ý³Ì¶ÔÏó

¹ØÓÚC++0x
Ô¤¼ÆÓÚÃ÷Äêµ×ÍÆ³öµÄбê×¼C++0x£¬Ëä˵ÒѽӽüÊչٽ׶Σ¬È´ÈÔÓÐÈô¸ÉÓдý½ÓÄɵÄÐÂÌá°¸±»Ìá³ö¡£ÓÈÆäÖµµÃ¹Ø×¢µÄÊÇ£¬Óëlambda±í´ïʽÒÔ¼°¾Ö²¿º¯ÊýÏà¹ØµÄÌá°¸“Unified Function Syntax£¨Í³Ò»µÄº¯ÊýÓï·¨£©”£¬¾¡¹Ü²»Êܱê׼ίԱ»á´ý¼û£¨Á½Äê¼äÀú¾­ËÄ´ÎÑÓ³Ù±í¾ö£¬Á½´Î²»Óèͨ¹ý£©£¬ÈÔÈ»“ÍçÇ¿µØ”ÍÆ³öÁ ......

Ruby 1.9²»»áɱËÀPython

      Ëɱ¾ÐкêÈçÔ¼ÓÚÊ¥µ®½Ú·¢²¼ÁËRuby 1.9¡£¸ù¾ÝRubyµÄ¹ßÀý£¬Ð¡ÊýµãºóÃæµÚһλÈç¹ûÊǵ¥Êý£¬ÄÇô¾Í±íÃ÷ÕâÊÇÒ»¸öʵÑé°æ±¾£¬²»ÍƼöÓÃÓÚ²úÆ·»·¾³¡£Ëùν“²úÆ·»·¾³”£¬¶ÔÓÚĿǰµÄRubyÀ´Ëµ£¬»ù±¾ÉϾÍÊÇRuby on Rails¡£´ÓĿǰRoRÉçȺµÄ·´Ó³À´¿´£¬È·ÊµÓÐÈËÕýÔÚ³¢ÊÔÓÃRuby 1.9ÅäºÏRoR£¬µ«ÊÇÉÐÊô ......

Ruby Shoes µÄÊó±êʼþ

ÒòΪһ´ÎżȻµÄ»ú»á½Ó´¥ÁËRubyÓïÑÔ¡£È»ºóÏÂÔØÁËRuby Shoes¹¤¾ß¡£
·¢ÏÖRuby»¹ÊÇÂùÓÐȤµÄ¡£
»¨ÁËÒ»¶Îʱ¼äÊìϤÁËËüµÄÓï·¨¡£
ÏÂÃæÀ´ÊÔÊÔËüµÄÊó±ê¹¦ÄÜ¡£
Shoes.app do
  #ͼƬ³õʼ»¯
  @img = image "http://www.google.cn/intl/zh-CN/images/logo_cn.gif"
  #ͼƬ¹ØÓÚÊó±êµÄµ÷ÓÃ
 & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ