我正在使用Google Apps脚本编写简单的电子邮件机器人处理程序.
说有一系列的东西.
我想使用for-each循环遍历数组.
(这很乏味,for(var i=0;i<threads.length;i++)每次我遍历一个数组都会写.)
我正在寻找谷歌应用程序脚本的for-each循环.
我已经看到了这个答案,但是对象是未定义的,大概是因为for循环不起作用.
// threads is a GmailThread[]
for (var thread in threads) {
var msgs = thread.getMessages();
//msgs is a GmailMessage[]
for (var msg in msgs) {
msg.somemethod(); //somemethod is undefined, because msg is undefined.
}
}
Run Code Online (Sandbox Code Playgroud)
(我还是javascript的新手,但我知道来自java的for-each循环.)
我最近遇到了一个.gitignore 文件,它以.gitignore 开头的一些换行符./。我不知道那些./s 做了什么,我很惊讶地发现这既 a) 一个看似新颖的问题,b) 很难找到答案。
我看过这些 相关的问题,但是./在 gitignores 中的功能似乎与在 bash 终端中的功能不同。
我的测试似乎表明./它没有做任何事情。给定文件夹结构:
C:.
? .gitignore
????bar
? bar0.txt
????baz
? baz0.txt
????foo
foo0.txt
Run Code Online (Sandbox Code Playgroud)
和一个 .gitignore
# .gitignore
./foo
./foo/*
./foo/
bar
/baz
Run Code Online (Sandbox Code Playgroud)
如果我这样做git add -A和git status,则只跟踪这些文件:
new file: .gitignore
new file: foo/foo0.txt
Run Code Online (Sandbox Code Playgroud)
那么,这样做的目的是./什么?
编辑:我在 Windows 上。