跳轉到內容

Scriptol/For In

來自華夏公益教科書,自由的教科書

通用語法

[編輯 | 編輯原始碼]

標準語法使用範圍內的元素為變數賦值,Scriptol 使用常見的寫法,在兩個值(或變數)之間使用雙點來表示範圍。


for int x in 0 .. 10
  print x
/for 


單行語法

[編輯 | 編輯原始碼]

如果結構體的主體只有一個語句,則使用簡化的語法。

for int x in 0 .. 10 print x 


For in 列表

[編輯 | 編輯原始碼]

for 控制結構可以像上面那樣掃描一個整數,也可以掃描一個文字或一個數組。

text hello = "hello"
for text t in hello print t 


array a = { 1, 2, 3 }
for dyn x in a print x
華夏公益教科書