Mercurial Hosting > luan
diff core/src/luan/impl/LuanImpl.java @ 662:ee00a619eec1
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 06 Apr 2016 21:47:45 -0600 |
parents | e064377994b2 |
children | b438a47196bc |
line wrap: on
line diff
--- a/core/src/luan/impl/LuanImpl.java Wed Apr 06 21:19:30 2016 -0600 +++ b/core/src/luan/impl/LuanImpl.java Wed Apr 06 21:47:45 2016 -0600 @@ -224,6 +224,15 @@ throw new LuanException( "attempt to index a " + Luan.type(t) + " value" ); } + public static Object pick(Object o,int i) { + if( i < 1 ) + throw new RuntimeException(); + if( !(o instanceof Object[]) ) + return null; + Object[] a = (Object[])o; + return i<a.length ? a[i] : null; + } + public static Object[] concatArgs(Object o1,Object o2) { if( o1 instanceof Object[] ) { Object[] a1 = (Object[])o1;