很简单的语法问题(10分)

  • 主题发起人 主题发起人 163.com
  • 开始时间 开始时间
1

163.com

Unregistered / Unconfirmed
GUEST, unregistred user!
我见到有类似的程序不知何解

if a in b then ...
1)请问 a in b 是什么意思
2)a,b 各应该是什么类型的值

能否给一个例子我参考(如果可以,请在例子上标上一些说明)
 
a可是任何类型
b是与a对应类型的一个集合,叫set型(可在帮助索引中打入sets查找帮助)
a in b表示a的值是否在b表示的这个集合中,返回Boolean值。
例:(切于delphi帮助)
type

TSomeInts = 1..250;
TIntSet = set of TSomeInts;

create a set type called TIntSet whose values are collections of integers in the range from 1 to 250. You could accomplish the same thing with

type TIntSet = set of 1..250;

Given this declaration, you can create a sets like this:

var Set1, Set2: TIntSet;

...
Set1 := [1, 3, 5, 7, 9];
Set2 := [2, 4, 6, 8, 10]

You can also use the set of ... construction directly in variable declarations:

var MySet: set of 'a'..'z';

...
MySet := ['a','b','c'];

Other examples of set types include

set of Byte

set of (Club, Diamond, Heart, Spade)
set of Char;

The in operator tests set membership:

if 'a' in MySet then ... { do something }
 
接受答案了.
 
后退
顶部