Project1

标题: 报错 [打印本页]

作者: pyypokemon    时间: 2016-9-10 06:25
标题: 报错
求教,我根据《RGSS3教程大家写.pdf》照搬例子,为什么报错……

RUBY 代码复制
  1. class Vector
  2.   attr_reader :X,:y
  3.   @@n = 0
  4.   def self.sum(*vecs)
  5.     x = y = 0
  6.     vecs.each{|v|x+=v.x;y+=v.y}
  7.     Vector.new(x,y)
  8.   end
  9.   def initialize(x,y)
  10.     @x = x
  11.     @y = y
  12.     @@n +=1
  13.   end
  14.   def Vector.report
  15.     @@n
  16.   end
  17.   NULL = Vector.new(0,0)
  18. end
  19.  
  20. a = Vector.new(1,2)
  21. b = Vector.new(2,4)
  22. c = Vector.sum(a,b,Vector::NULL)
  23. msgbox "("+c.x.to_s+","+c.y.to_s+")"



作者: 喵呜喵5    时间: 2016-9-10 08:55
第二行,x是小写不是大写
作者: pyypokemon    时间: 2016-9-10 20:38
喵呜喵5 发表于 2016-9-10 08:55
第二行,x是小写不是大写

= =好吧……难怪我找不到哪里不对……原来不小心敲成大写了……
作者: pyypokemon    时间: 2016-9-14 06:32
喵呜喵5 发表于 2016-9-10 08:55
第二行,x是小写不是大写

前辈,用点评写:“认可答案” 可以吗?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1