如何在Kotlin中创建常量?什么是命名惯例?我没有在文档中找到它.
companion object {
//1
val MY_CONST = "something"
//2
const val MY_CONST = "something"
//3
val myConst = "something"
}
Run Code Online (Sandbox Code Playgroud)
要么 ...?
在Elixir中生成UUID的规范方法是什么?我是否必须使用库https://hex.pm/packages/uuid或是否有内置库?我更好地拥有更少的依赖关系并且做更多的工作而不是反之亦然,因此如果我可以在Elixir中生成具有外部依赖性的东西,那么最好还是使用它.
我有这个:
case test123(&(:some_module.test456(789))) do
# ...
end
Run Code Online (Sandbox Code Playgroud)
一个错误:
invalid args for &, expected an expression in the format of &Mod.fun/arity,
&local/arity or a capture containing at least one argument as &1,
got: :some_module.test456(789)
Run Code Online (Sandbox Code Playgroud)
但是,我没有要传递给它的参数,以前它只是
fn(_) -> :some_module.test456(789) end
Run Code Online (Sandbox Code Playgroud)
如何解决?切换回“ fn”?
我已经发布了我的箱子,然后意识到我忘了在我的脑袋中加入一些小细节README.md.我已经提供了详细的进 README.md,做git commit和push.如何在不更改版本的情况下更新我的箱子?
cargo yank在您发布实际上因某种原因而最终被破坏的箱子版本(语法错误,忘记包含文件等)时,可能会出现这种情况.对于这种情况,Cargo支持
yank一个版本的板条箱.Run Code Online (Sandbox Code Playgroud)$ cargo yank --vers 1.0.1 $ cargo yank --vers 1.0.1 --undo
我不明白如何使用它.为什么有两个命令:一个没有--undo?我应该同时运行它们吗?还是只有一个?哪一个?
我应该crate package && crate publish追赶吗?还是只cargo yank ...?这会自动更新我的箱子吗?
我正在尝试在REPL中导入Idris中的Socket:
Idris> :module Network.Socket
Can't find import Network/Socket
Run Code Online (Sandbox Code Playgroud)
为什么?
在Idris中定义我们称之为常量的惯用方法是什么?是这个吗?
myConstant : String
myConstant = "some_constant1"
myConstant2 : Int
myConstant2 = 123
Run Code Online (Sandbox Code Playgroud)
如果是这样,在REPL中我在声明后得到一个例外:
(input):1:13: error: expected: "$",
Run Code Online (Sandbox Code Playgroud) 在Rust GTK的例子中,有一个叫做笔记本.它不编译:
for i in 1..4 {
let title = format!("sheet {}", i);
let label = gtk::Label::new(Some(&title));
//let label = gtk::Label::new(Some("test1111")); # works well
notebook.create_tab(&title, label.upcast());
}
Run Code Online (Sandbox Code Playgroud)
错误是:
the trait bound `std::option::Option<&str>: std::convert::From<std::option::Option<&std::string::String>>` is not satisfied
Run Code Online (Sandbox Code Playgroud)
它是什么以及如何解决它?
我需要发送DNS请求来检查域的A,AAAA,MX和SOA记录.
有两个流行的DNS库:trust-dns和dns-parser.他们俩都没有例子.trust-dns不支持我需要做的事情,而dns-parser的文档也无济于事.
在我的Phoenix应用程序中,我想向URL添加查询字符串:
some_cool_path(@conn, :index, "view-mode": "table")
Run Code Online (Sandbox Code Playgroud)
我希望它会生成类似的URL /some_cool?view-mode=table,但会引发异常:
protocol Phoenix.Param not implemented for ["view-mode": "table"]
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我有这个:
a1 = [%{id: 1, val: 12}, %{id: 3, val: 7}, %{id: 1, val: 5}, %{id: 2, val: 3}, %{id: 2, val: 5}], %{id: 1, val: 3}]
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这个?
%{
1 => 20,
2 => 8,
3 => 7
}
Run Code Online (Sandbox Code Playgroud)
也就是说,按"id"分组的每个项目的"val"之和
我应该先用"id"将它们分组吗?
Enum.group_by a1, &(&1.id)
# =>
%{
1 => [%{id: 1, val: 12}, %{id: 1, val: 3}, %{id: 1, val: 5}],
2 => [%{id: 2, val: 3}, %{id: 2, val: 5}],
3 => [%{id: 3, val: 7}]
}
Run Code Online (Sandbox Code Playgroud)
然后做map …
elixir ×4
idris ×3
rust ×3
android ×1
constants ×1
dictionary ×1
dns ×1
gtk ×1
kotlin ×1
package ×1
rust-cargo ×1
rust-crates ×1