我想声明一个具有“索引”类型的表
import { createSelector } from 'reselect';
import existsAt from '../../../utils/objectExistsAtPath';
import {
nameToBlockData,
HOME_DATA_FEATURE_PARKS,
} from '../../../api/json-name-to-block-data';
const R_BASE = 'home.data.blocks';
// eslint-disable-next-line
const getParksData = (state, position) => (existsAt(R_BASE, state) ? nameToBlockData(state.home.data.blocks, HOME_DATA_FEATURE_PARKS).sub_blocks.find(element => element.position === position) : {});
export default createSelector(
[getParksData],
(parksData) => (parksData),
);
答案 0 :(得分:3)
我不确定您要做什么,但是您可以列出清单
由SalchiPapa推荐,也与原始帖子中一样... index = PM []
struct PM
npm
nvm
end
indexes = PM[]
push!(indexes,PM(1,"s"))
push!(indexes,PM(2,"s"))
push!(indexes,PM(1,"m"))
push!(indexes,PM(2,"m"))
println(indexes)
输出是这些结构的列表
Any[PM(1, "s"), PM(2, "s"), PM(1, "m"), PM(2, "m")]
请注意,如果您知道npm
和nvm
是什么类型,我建议说明一下它们,即npm
看起来总是integer
,而{{ 1}}看起来总是nvm
String
您可以简单地访问这些元素,例如:
struct PM
npm::Int64
nvm::String
end
在这种情况下输出indexes[2].npm
和2
会输出indexes[2].nvm
。