开发者

How do I manipulate a lowlevelarray in Opa?

开发者 https://www.devze.com 2023-04-11 12:11 出处:网络
For instance, how do I create a LowLevelArray that contains a set of integers: 1, 2, 3, 4, and 5? My understanding is that the easy way is to do myarray = @llarray(1, 2, 3, 4, 5) and that\'s great. B

For instance, how do I create a LowLevelArray that contains a set of integers: 1, 2, 3, 4, and 5?

My understanding is that the easy way is to do myarray = @llarray(1, 2, 3, 4, 5) and that's great. But how do I loop t开发者_运维百科hrough the array to pull out values and println them?

I tried do inrange(0,4,(i -> println("{myarray.get(i)}"))) but get the error: Record expression has type llarray(int) but field access expected it to have type { get: 'a; 'r.a }


Take a look at the docs. Instead of myarray.get(i) you'll have to write LowLevelArray.get(myarray, i) (you can make an abbreviation for the LowLevelArray module, or even the getter for a particular array, if that's too verbose for you).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号