Skip to content

Commit cae29b2

Browse files
committed
增加获取List的第一个和最后一个元素的方法
1 parent 1db245f commit cae29b2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

base/zbase.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,18 @@ namespace List {
400400

401401
list.clear();
402402
args.first().depthCopyAssign(list);
403+
404+
return ZVariant();
405+
}
406+
407+
ZVariant last(const QList<ZVariant> &args)
408+
{
409+
return args.first().toList().last();
410+
}
411+
412+
ZVariant first(const QList<ZVariant> &args)
413+
{
414+
return args.first().toList().first();
403415
}
404416
}// end namespace List
405417

@@ -450,5 +462,7 @@ void init()
450462
REGISTER_FUNCTION(ZVariant::List, List::replace);
451463
REGISTER_FUNCTION(ZVariant::List, List::join);
452464
REGISTER_FUNCTION(ZVariant::List, List::clear);
465+
REGISTER_FUNCTION(ZVariant::List, List::last);
466+
REGISTER_FUNCTION(ZVariant::List, List::first);
453467
}
454468
}// end namespace ZBase

0 commit comments

Comments
 (0)