执行这样的循环会是不好的做法吗?我正在循环遍历所有汽车,并将文本“新”附加到每种颜色的名称中。每辆车可以有多种颜色。
var cars = [
{
company: "honda",
colors: [
{
name="burntRed"
},
{
name: "springGreen"
}
]
},
{
company: "ford",
colors: [
{
name="burntOrange"
},
{
name: "black"
}
]
}
];
for (var c = 0; c < cars.length; p++) {
var car = cars[c];
for (var i = 0; i < cars.colors.length; i++) {
car.color[i].name += 'new ' + car.color[i].name;
};
};
Run Code Online (Sandbox Code Playgroud) 我很困惑我在这里失踪了什么.我是榆树的新手,但我不知道这是怎么回事:
move : List Char -> Char -> Int
move board symbol =
let
grid =
fromList board
found =
((get 0 grid == symbol) && (get 1 grid == symbol) && (get 2 grid == symbol))
|| ((get 4 grid == symbol) && (get 4 grid == symbol) && (get 5 grid == symbol))
in
if found then
1
else
0
Run Code Online (Sandbox Code Playgroud)
错误:
The = operator is reserved for defining variables. Maybe you want == instead? Or
maybe you are …Run Code Online (Sandbox Code Playgroud) 我无法想出一个简单的方法来过滤掉这个Dict中的前3个项目
fruit =
fromList
[ ( ( 0, 0 ), "apple" )
, ( ( 0, 1 ), "orange" )
, ( ( 0, 2 ), " " )
, ( ( 1, 0 ), " " )
, ( ( 1, 1 ), " " )
]
Run Code Online (Sandbox Code Playgroud)
我已经查看了Dict的文档,但是没有看到任何简单的方法来查询前3个到另一个Dict,所以我可以稍后再做那些前3个
尝试不渲染任何内容或根据 users 变量渲染 DOM 元素:
const Users = (props: UserProps) => {
const [users, setData] = useState([]);
useEffect(() => {
...
}, []);
return (
users && (
<span>
<div className="padding-bottom-50">
<div className="section-heading">
New Users
</div>
<Users users={users} />
</div>
</span>
) || null
);
};
Run Code Online (Sandbox Code Playgroud)
"New Users"即使用户为空或未定义,它仍然显示文本
对我来说似乎没问题,但我的列表仍然没有按我的键排序。
var tagNamesAndRoutes = new Dictionary<string, string>();
foreach (string name in tagNames)
{
tagNamesAndRoutes.Add(name, routeConstant);
}
Run Code Online (Sandbox Code Playgroud)
字典值示例:
Key Value
"NUnit" "/Category"
"WCF" "/Category"
"ReSharper" "/Category"
Run Code Online (Sandbox Code Playgroud)
等等。
我尝试通过典型的 LINQ 对其进行排序:
tagNamesAndRoutes.OrderBy(c => c.Key);
Run Code Online (Sandbox Code Playgroud)
但事实并非如此。
第一次使用 AWS 实例。这是我所做的:
它要求输入密码,但我不知道它是什么
sudo ssh -i my.pem ubuntu@54-86-186-87
Run Code Online (Sandbox Code Playgroud)
尝试从 OS X ssh
我想既然我使用的是密钥 (.pem),我就不需要担心任何密码?
在进一步故障排除期间:
当我运行时ec2-get-console-output instance_id,它显示我的实例在ubuntu用户之下,并且ssh-rsa运行该命令的结果中显示的指纹与我的密钥名称不同 ( Authorized keys from /home/ubuntu/.ssh/authorized_keys for user ubuntu.. 事实上,它显示的指纹甚至比我的实例在我的实例的 AWS 仪表板中。
该 ssh-rsa 密钥不应该与 AWS 控制面板中为我的实例显示的相同并匹配我的本地私有 .pem 吗?
不清楚为什么当有9个空字符串时,这会返回0.
function isEmpty(){
const emptySlots = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '].filter(slot => { slot === " "})
return emptySlots.length === 9; // emptySlots.length is 0 for some reason
}
Run Code Online (Sandbox Code Playgroud) I've got an ASW Host running Ubuntu and I don't see an etc folder such as what is referenced in these docs.
Why is that?
I also don't see a /usr/local/bin folder
When I do an ls -a I get: