2017-07-24 69 views
1

運行稔0.17.0或更新版本,在Windows 8.1測試與VCC 2017年工具鏈運行,如下的編譯過程中產生的錯誤:從算法模塊「排序」給出模棱兩可的/無類型錯誤

import algorithm 

var toSort = @["b", "c", "d"] 
for sorted in toSort.sort(system.cmp): 
    echo sorted 

我Nim非常新,但是我的sort電話會遇到什麼問題?

回答

1

sort程序不返回任何東西。它就地修改了列表。你想用sorted代替:

import algorithm 

var toSort = @["b", "c", "d"] 
for sorted in toSort.sorted(system.cmp): 
    echo sorted 
+0

李自成的代碼示例從[排序文件(https://nim-lang.org/docs/algorithm.html#sort,openArray [T],PROC(T ,T))現在讓我明白這一點。謝謝! – bsinky