我刚刚阅读了Logger gem文档,关闭该方法引起了我的注意。现在我想知道是否在使用后必须关闭记录器文件,例如:
log = Logger.new("foo.log")
# program here logging things
log.close
Run Code Online (Sandbox Code Playgroud)
我以前从未关闭过它,这似乎不是问题,也许它会在程序完成时自动关闭?
我正在使用Leaflet.js在地图中显示geojson文件,我有以下代码:
// Set the map and the geojson as pointed in the tutorials
var geojsonLayer = new L.GeoJSON(null, {
onEachFeature: function (feature, layer) {
if (feature.properties) {
var popupString = '<div class="popup">';
for (var k in feature.properties) {
var v = feature.properties[k];
popupString += k + ': ' + v + '<br />';
}
popupString += '</div>';
layer.bindPopup(popupString, {
maxHeight: 200
});
}
}
});
map.addLayer(geojsonLayer);
L.control.layers({'Road': road_layer, 'Satellite': satellite_layer}, {'GeoJSON': geojsonLayer}).addTo(map);
//...
// Load file and get …Run Code Online (Sandbox Code Playgroud) 任何人都可以解释为什么 DateTime.parse返回这个,而不是失败,这是我在传递无效日期时所期望的行为?
require 'date'
DateTime.parse "X5pxmDwewKlIgJ_G0HX6TI2sMoY1XOgOcz09oQ4RO9U"
=> #<DateTime: 2017-01-09T00:00:00+00:00 ((2457763j,0s,0n),+0s,2299161j)>
Run Code Online (Sandbox Code Playgroud)
我试图只留下数字,但随后它给出了ArgumentError: invalid date,我也尝试修改一点字符串,但同样,它失败了:
DateTime.parse "X5px4fGHewKlIgJ_G0635I2sMoY1XOgOcz09oQ4ROA1"
ArgumentError: invalid date
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?