線上 Ruby 格式化程式

幫助 教程 程式設計基礎 檢視 編輯 開發工具
線上影像最佳化程式
線上 LaTeX 編輯器
LaTeX 方程編輯器
白板
線上影像編輯器
線上 XML 編輯器
線上 JSON 編輯器
檔案轉換
更多工具...
撤銷
恢復
剪下
複製
貼上
刪除
全選
查詢
查詢並替換
編輯器主題
Chrome
Crimson Editor
Dreamweaver
Eclipse
Github
Kuroir
Solarized Light
Solarized Dark
XCode
Ambiance
Cobalt
idle Fingers
krTheme
Mono Industrial
Monokai
Terminal
Textmate
Tomorrow
Twilight
Vibrant Ink
字型大小
8px
9px
10px
11px
12px
13px
14px
15px
16px
17px
18px
20px
22px
24px
製表符大小
1
2
3
4
5
6
7
8
自動換行
40 個字元
60 個字元
80 個字元
100 個字元
120 個字元
140 個字元
顯示不可見字元
隱藏不可見字元
顯示導航欄
隱藏導航欄
下載
#!/usr/bin/ruby -w

# define a class
class Box
# constructor method
def initialize(w,h)
@width, @height = w, h
end

# accessor methods
def getWidth
@width
end
def getHeight
@height
end

# setter methods
def setWidth=(value)
@width = value
end
def setHeight=(value)
@height = value
end
end

# create an object
box = Box.new(10, 20)

# use setter methods
box.setWidth = 30
box.setHeight = 50

# use accessor methods
x = box.getWidth()
y = box.getHeight()

puts "Width of the box is : #{x}"
puts "Height of the box is : #{y}"
© 版權所有 2023。保留所有權利。
美化 | 上傳檔案 上傳檔案