-
Notifications
You must be signed in to change notification settings - Fork 3
Range en
The Range class is a class indicating range. It is made with Generics and Generics needs to implement the ISortable interface. It is made by Generics so that it can be implemented even in Char class, etc., but normally you will only use Integer class. The representation of the value is
1..2
3..4
1..5
Etc. The implemented method is isMember (value: T): bool. It judges whether the value of value is within the range. It is important to note that to send a message to a Range object it is necessary to enclose the Range object in parentheses. This is based on the fact that there is nothing on the parser.
(1..5).isMember (3) # -> true
Etc. Because the range value can also include message passing, it can not be distinguished by the parser. The following cases can not be distinguished.
1.object.hoge().IsMember ()
- It is impossible to judge whether the object is in range or 1. object.hoge () is in range. To message passing to the Range object, enclose parentheses.
As it is, it is a very useless object, but you can use Range object in a method that accepts range as argument of method.
"ABCDEGHI" .subString (1..3) # -> "BC"
{1, 2, 3, 4, 5}. subList (2..4) # -> {3, 4}
Etc. In the standard library, Range does not include the last value in range at first. It is because it is like Python. It was because it was easier to use in personal feeling of writing the code. Including the last value in the range is often a lot troublesome. I learned from Python. For details of the Range class, see Range.clcl included in clover 2. Methods of String, List, and Buffer class using Range class are summarized there. Please check out Range.clcl if you like. I make the Range class simple. If you feel like it, please add some method by the user.
- フリーフォーマット
- 変数と関数について
- 条件分岐と演算子
- 論理演算子
- ビット演算子
- ループ
- ブロック
- コメント
- アノテーション
- ナルエイブル
- プリミティブクラス
- 配列
- クラス
- クラスフィールドとクラスメソッド
- dynamic_class
- boxingとunboxing
- プリミティブ型とスペシャルフィールド
- スペシャルメソッド
- インターフェース
- 移譲
- モジュール
- ジェネリクス
- メソッドジェネリクス
- 関数
- 列挙型(enum)
- 自動setterとgetterの定義
- when文
- 変数の宣言の取り消し
- 例外処理
- 多重代入
- 代入時の自動キャスト
- C言語へのFFI
- ローカル変数の宣言
- メモリーセーフなポインタ
- 例外演算子
- 糖衣構文