答案 0 :(得分:4)
要检查object
是否为object[]
,您的支票element is object[]
已经正确无误。
要检查object[]
是否为空,请调用Any()
已正确,但请务必在正确的实例上调用它。避免使用ToEnumerable()
扩展方法,因为它没有按照您的希望进行。
if (element is object[] && !((object[]) element).Any())
// element is an empty array of objects
测试:
using System;
using System.Collections.Generic;
using System.Linq;
namespace Tester {
static class Program {
static void Test(string name, object element) {
Console.Write($"{name}: ");
Console.WriteLine(element is object[] && !((object[])element).Any());
}
static void Main(string[] args) {
Test("new object()", new object()); // false
Test("new { }", new { }); // false
Test("new object[0]", new object[0]); // true
Test("new object[1]", new object[1]); // false
Test("new List<object>()", new List<object>()); // false
// Note: object[] o = new List<object>(); wouldn't be allowed.
Test("new string[0]", new string[0]); // true
// Note: object[] o = new string[0]; would be allowed.
Test("new int[0]", new int[0]); // false
// Note: object[] o = new int[0]; wouldn't be allowed.
}
}
}
这包括一些测试用例,可能表明您尝试进行的检查不是一个好主意,但它也表明它可以提供准确的结果。
答案 1 :(得分:1)
没有class BuildHistory {
// unpinall doesnt seem to wok so force it and return result
class func removeOldTable(className: String, completeBlock: @escaping (Bool) -> Void) {
let queryRem = PFQuery(className: className)
queryRem.fromLocalDatastore()
queryRem.findObjectsInBackground { (objects, error) in
if objects != nil {
PFObject.unpinAll(inBackground: objects)
completeBlock(true)
}
}
}
类型。它告诉你的是它是一个空的对象数组。
答案 2 :(得分:1)
你试过了吗?
var materials = [new THREE.MeshBasicMaterial({map: texture, side: THREE.FrontSide}),
new THREE.MeshBasicMaterial({map: textureBack, side: THREE.BackSide})];
var geometry = new THREE.PlaneGeometry(width, height);
for (var i = 0, len = geometry.faces.length; i < len; i++) {
var face = geometry.faces[i].clone();
face.materialIndex = 1;
geometry.faces.push(face);
geometry.faceVertexUvs[0].push(geometry.faceVertexUvs[0][i].slice(0));
}
scene.add(new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials)));