Connect IQ > APIメモ > Toybox > Lang


下位ページ

Content

Module: Toybox::Lang


Monkey C 言語の基本型を提供する

  • Number : 32 bit 符号付き整数
  • Float : 32 bit 浮動小数点数
  • Long : 64 bit 整数
  • Double : 64 bit 浮動小数点数
  • Booleans : 真偽値
  • Symbols : 軽量な定数
  • Strings : 文字列
  • Objects : Instantiated objects are defined with the class keyword. Classes are bindings of names to values.
  • Dictionaries - Associative arrays, allocated with the syntax “new {}” or just “{}”
  • Arrays : Arrays, allocated with the syntax “new [X]” where X is an expression computing the size of the array
  • Exceptions : The base type for an error that can be handled in code with a try/catch. Used with the throw keyword.

  • Since : 1.0.0

Defined Under Namespace

  • Classes: Array, Boolean, Dictionary, Double, Exception, Float, Long, Method, Number, Object, String, Symbol, UnexpectedTypeException, WeakReference

Instance Method Summary

(collapse)

   - (String) format(format, params)

   Use format() to create a formatted String by substituting the given parameters into the given format at the corresponding locations.

Instance Method Details

(String) format(format, params) : フォーマット化された文字列を生成する

与えられたフォーマットに対し、与えられパラメータ値を用いて、文字列を生成する。
  • 与えられたフォーマット : "Your next meeting is at $1$:$2$ on $3$ $4$ in room $5$."
  • 与えられたパラメータ : [2, 30, "Sep", 4, "6820"]
  • 出力される文字列 : "Your next meeting is at 2:30 on Sep 4 in room 6820."

  • Parameters
    • format (String) : A string using $1$, $2$, $3$… as substitution identifiers
    • params (Array) : Array of content to substitute in
  • Returns : (String) A new String with the substituted content
  • Since : 1.0.0

Class: Toybox::Lang::Float

32ビット浮動小数点数。'd'のプレフィックスがつかない限り、10進小数はデフォルトで Float になる。
  • Since : 1.0.0

関数(要約) Float

  • (Float) abs : Use abs() to get the Absolute value of the Float.
  • (String) format(format) : Use format() to format the Float using the given formatting String.
  • (Double) toDouble : Convert the Float to a Double with toDouble().
  • (Float) toFloat : Convert to a Float with toFloat().
  • (Long) toLong : Convert the Float to a Long with toLong().
  • (Number) toNumber : Convert the Float to a Number with toNumber().

Instance Method Details

(Float) abs : 絶対値を返す

  • Returns : (Float) Floatの絶対値
  • Since : 1.0.0

(String) format(format) : フォーマット文字列を用いて、指定した表示形式の文字列を取得する

フォーマット文字列は c言語の printf 関数のフォーマットに類似する。([length] オプション は使用できない):

  • "%[flags][width][.precision]specifier"
    • The supported specifiers are: d, i, u, o, x, X, f, e, E, g, G.
    • flags : supports only "+" and "0"
    • width : supports only numbers (* is not supported)
    • .precision : supports only numbers (* is not supported)
  • Returns : (String) A formatted String
  • Since : 1.0.0

(Double) toDouble : Double型に変換する

  • Returns : (Double) A Double object
  • Since : 1.0.0

(Float) toFloat : Float へ変換する

  • Returns : (Float) A Float object
  • Since : 1.0.0

(Long) toLong : Long 型へ変換する

  • Returns :(Long) : A Long object
  • Since : 1.0.0

(Number) toNumber : Number 型へ変換する

値は 0 に向かって丸められる。例)6.8 → 6、-5.7 → -5
  • Returns : (Number) A Number object
  • Since : 1.0.0
最終更新:2016年03月02日 23:47