我在响应头中设置了Cache控件Cache-Control:public, max-age=86400.但是当我尝试刷新页面或打开一个新选项卡时,它总是会打到我的服务器.我得到的响应状态是200,此请求出现了服务器日志,我也检查了chrome://cache/此请求不在列表中.我已经看过一些类似的SO问题缓存控制没有etag工作,为什么缓存控制:max-age不起作用?.但仍然没有运气.测试铬56.
我想要一个函数来测试类变量是否不存在null,并在后续函数调用中使用它。但遭到了 TS 的投诉。封装这个验证函数,因为我需要在许多方法中调用它。
class A {
point: Point | null
validatePoint() {
if (!this.point) throw new Error()
}
update(p: Point | null) {
this.validatePoint()
// ts complains this.point can be null
doSomething(this.point)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 REPL 中运行 scala cats。按照 cat 的指示,我安装了 ammonite REPL 并将以下导入放入predef.sc
nterp.configureCompiler(_.settings.YpartialUnification.value = true)
import $ivy.`org.typelevel::cats-core:2.2.0-M1`, cats.implicits._
Run Code Online (Sandbox Code Playgroud)
我在运行时遇到此错误amm。
predef.sc:1: value YpartialUnification is not a member of scala.tools.nsc.Settings
val res_0 = interp.configureCompiler(_.settings.YpartialUnification.value = true)
^
Compilation Failed
Run Code Online (Sandbox Code Playgroud)