簡體   English   中英

Smalltalk Matrix無錯誤

[英]Smalltalk Matrix nil error

因此,我在pharos 6.0的操場上運行了這段代碼,它給我一個錯誤,指出“無法對unindex對象進行訪問。基本上,我正在嘗試制作一個8x10的矩陣。我如何制作一個?

  | aMatrix row col|


  aMatrix := Matrix new.
  aMatrix numberOfColumns: 3.
  aMatrix numberOfRows: 3. 
  aMatrix at: 2 at: 2 put: 6.

如果您嘗試制作8x10矩陣,為什么要這樣做

aMatrix numberOfColumns: 3.
aMatrix numberOfRows: 3. 

我檢查了代碼,但不知道為什么以這種方式實現。 numberOfColumns:numberOfRows:僅將參數分配給實例變量,但不更改內部數據結構。

您應該執行以下操作:

aMatrix := Matrix rows: 8 columns: 10.   
aMatrix at: 2 at: 2 put: 6.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM