mojodojodev / mojodojo.dev

Learning materials for the Mojo🔥programming language
https://mojodojo.dev/
88 stars 16 forks source link

Update Buffer.md #13

Closed santhosh-patel closed 1 year ago

santhosh-patel commented 1 year ago

let p = DTypePointer[DType.ui8].alloc(8) let x = Buffer8, DType.ui8

Error:

Expression [21]:21:31: 'DType' value has no attribute 'ui8' let p = DTypePointer[DType.ui8].alloc(8)



Expression [21]:22:28: 'DType' value has no attribute 'ui8'
    let x = Buffer[8, DType.ui8](p)
                      ~~~~~^~~~

Suggested Solution:

let p = DTypePointer[DType.uint8].alloc(8)
let x = Buffer[8, DType.uint8](p)

Explanation:
The error occurs because the attribute ui8 does not exist in the DType class. The correct attribute to use is uint8 instead. By replacing DType.ui8 with DType.uint8, the code should work as intended.
mojodojodev commented 1 year ago

Thanks for this