我正在研究使用结构作为golang地图中的键.此结构中的字段也应该是一个映射,这似乎违背了此处提供的文档,该文档说明只有具有可以与之比较的字段的结构,==
并且!=
可以在用作映射中的键的结构字段中.然而,我继续尝试以下方法:
package main
import "fmt"
import "strings"
func main() {
fmt.Println("Hello, ??")
fmt.Println(strings.Join([]string{"obi", "$", "56"}, ""))
z := make(map[string]float64)
z["obi"] = 0.003
x := &test{
name:"testing",
code:z,
}
a := &test{
name:"testing2",
code:z,
}
y := make(map[*test] string)
y[x] = "go home"
y[a] = "come home"
for key, val := range y{
fmt.Println(key.name, key.code, val)
}
}
type test struct{
name string
code map[string]float64
}
Run Code Online (Sandbox Code Playgroud)
输出是:
Hello, ??
obi$56
testing map[obi:0.003] go home
testing2 …
Run Code Online (Sandbox Code Playgroud) 我有一张假桌子.我使用border-spacing属性在它们之间创建一个空格.但这也会在第一个细胞之前和最后一个细胞之后产生间距.
我希望它只在这两列之间创建一个空格.
HTML:
<div class="table">
<div class="cell"></div>
<div class="cell"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.table {
display: table;
width: 100%;
border-spacing: 11px 0;
border: 1px solid #222;
}
.cell {
display: table-cell;
width: 50%;
height: 20px;
border: 1px solid #999;
background: #ccc;
}
Run Code Online (Sandbox Code Playgroud)
JSFiddle:http://jsfiddle.net/ACH2Q/
var path;
for (var i = 0, c = paths.length; i < c; i++)
{
path = paths[i];
fs.lstat(path, function (error, stat)
{
console.log(path); // this outputs always the last element
});
}
Run Code Online (Sandbox Code Playgroud)
如何访问path
传递给fs.lstat函数的变量?
当按下某个键时,如何退出无限循环?目前我正在使用getch,但它会尽快开始阻止我的循环,因为没有更多的输入要读取.
这是工作代码:
var test = function ()
{
console.log(test.data);
};
test.data = 'hello';
test.set = function (data)
{
test.data = data;
};
test.set('Test');
test();
Run Code Online (Sandbox Code Playgroud)
这输出Test
到我的JavaScript控制台.现在我想知道,如果有办法使用这样的东西吗?
var test = {
this: function ()
{
console.log(test.data);
},
data: 'hello',
set: function (data)
{
test.data = data;
}
};
Run Code Online (Sandbox Code Playgroud) 我知道你graphics.clear
用来清除所有图形,但是清除了舞台上的图形,我想清除特定像素中的图形或xy值之间的图像我该怎么做?
javascript ×2
node.js ×2
actionscript ×1
asynchronous ×1
c ×1
clear ×1
css ×1
css-tables ×1
dictionary ×1
for-loop ×1
function ×1
getch ×1
go ×1
graphics ×1
object ×1
scope ×1