typeof(x)

阅读(3545) 标签: 获取, 数据类型,

描述:

获取变量x的数据类型。

语法:

typeof(x)

备注:

获取变量x的数据类型。支持的数据类型有:null, bool, number, bytes(排号), datetime, string, blob, sequence(序列), record(记录), table(二维表)

参数:

x

变量。

选项:

@x

xnumberdate类型时,进一步细分数据类型。

number可分为:int,long,float,decimal

date可分为:date,time,datetime

返回值:

字符串

示例:

 

A

 

1

 

 

2

=typeof(A1)

null

3

=typeof(true)

bool

4

=typeof(123)

number

5

=typeof("abdfs")

string

6

=typeof(blob([4,7,3]))

blob

7

=typeof(k(1))

bytes

8

=typeof([1,2])

sequence

9

=typeof(now())

datetime

10

=2.new(~:id)

 

11

=typeof(A10)

table

12

=typeof(A10(1))

record

13

=typeof@x(now())

datetime

14

=typeof@x(date(now()))

date

15

=typeof@x(time(now()))

time

16

=typeof@x(123)

int

17

=typeof@x(1.23)

float

18

=typeof@x(long(123232))

long

19

=typeof@x(decimal("123456789012345678901234567890"))

decimal