通过批处理文件创建没有重复项的元素集合

时间:2018-12-01 09:53:22

标签: batch-file for-loop iteration

我正在自定义工具上运行多个class CategoryViewController: SwipeTableViewController { let realm = try! Realm() var categoryarray: Results<Category>? var todoItems: Results<Item>? var todoVC = TodoListViewController() override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = super.tableView(tableView, cellForRowAt: indexPath) if let category = categoryarray?[indexPath.row] { cell.textLabel?.text = category.name cell.backgroundColor = UIColor(hexString: category.colour) cell.textLabel?.textColor = ContrastColorOf(UIColor(hexString: category.colour)!, returnFlat: true) cell.detailTextLabel?.text = "\(todoItems?.count ?? 0)" } 循环,该循环生成结果数组。

我需要将它们压平成一个集合,没有重复

我的第一个想法是创建键为项目的数组,请参见下文。但这是以后要迭代的噩梦...:

for

2 个答案:

答案 0 :(得分:1)

只需钉上它:

delimiter $$
CREATE TRIGGER `subtract_inv` AFTER INSERT ON `order_details` FOR EACH ROW 
begin
    update inventory join 
    (select r.inventory_inv_id rinvid,new.order_details_qty * r.Requiered_qty adjustment
    from recipes r join inventory i  on i.inv_id  = r.inventory_inv_id 
    where r.products_prod_id = new.products_prod_id) s
    set inv_qty = inv_qty - s.adjustment
    where inventory.Inv_ID = s.rinvid;
end $$
delimiter ;

答案 1 :(得分:1)

您的想法是通过数组获取没有重复的元素。我只建议您将引号variable=value的{​​{1}}部分放在引号之间;这是避免出现可能未分配给变量的空格的好习惯。

创建数组后,可以用非常简单的方式迭代元素:

set