LoginSignup
0
0

More than 5 years have passed since last update.

Monkey CでArrayにPushする

Posted at

Connect IQ のArrayオブジェクトにPushがないので作りました。

function pushArray(array, obj){
    array.add(obj);
    array = array.slice(1, null);
    return array;
}

テストコード

    var myArr = [1,2,3,4,5];
    System.println(pushArray(myArr,6));
    // 出力 [2,3,4,5,6]

参考

Arrayオブジェクト https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/Lang/Array.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0