回答編集履歴

2

コード追記

2016/03/10 09:39

投稿

masarusan24
masarusan24

スコア55

test CHANGED
@@ -33,3 +33,37 @@
33
33
  >50
34
34
 
35
35
  >50
36
+
37
+
38
+
39
+ 無理矢理nilを出力させようとするならこんな感じでしょうか。
40
+
41
+
42
+
43
+ ```ruby
44
+
45
+ def area(x,y)x*y if x end
46
+
47
+
48
+
49
+ class Rect
50
+
51
+ def initialize(x,y)@x,@y=x,y end
52
+
53
+ attr_reader :x,:y
54
+
55
+ def area()x*y if x end
56
+
57
+ end
58
+
59
+
60
+
61
+ puts area(nil,nil)
62
+
63
+ puts Rect.new(nil,nil).area
64
+
65
+ puts area(10,5)
66
+
67
+ puts Rect.new(10,5).area
68
+
69
+ ```

1

インデント編集

2016/03/10 09:39

投稿

masarusan24
masarusan24

スコア55

test CHANGED
@@ -12,13 +12,11 @@
12
12
 
13
13
  class Rect
14
14
 
15
-
16
-
17
15
  def initialize(x,y)@x,@y=x,y end
18
16
 
19
- attr_reader :x,:y
17
+ attr_reader :x,:y
20
18
 
21
- def area()x*y end
19
+ def area()x*y end
22
20
 
23
21
  end
24
22