Class clazz = new Object(){}.getClass();
Run Code Online (Sandbox Code Playgroud)
为什么这可能,这意味着什么?有人可以提醒我吗?
例如:
public class Testing {
public static void main(String[] args) {
Class clazz = new Object(){}.getClass();
System.out.println(clazz);
}
}
Run Code Online (Sandbox Code Playgroud)
结果是: class Testing$1
我在Linux中使用git作为我的本地项目,我只有一个人.我想与使用Windows的另一台机器上的其他人分享我的项目.我怎么能这样做?
我有一本关于git的书,但仍然无法弄清楚如何处理它.例如,它表示其他用户可以键入:
git clone my.ip.add.ress:/home/myuser/projects/myproject
Run Code Online (Sandbox Code Playgroud)
但是当这个人这样做时,它会在我的机器中询问用户的密码.除了我自己,我没有在我的机器上注册任何其他用户.当然,我可以:
adduser)中注册新用户,然后这个用户(developer2)可以执行如下命令:
my.ip.add.ress:/home/developer2/projects/myproject
Run Code Online (Sandbox Code Playgroud)
但我想这不是一个好的解决方案.
我有我的匹配:
val product = parser next match {
case EvElemStart(_, "Product", attrs, _) =>
Some(parseProduct( parser, attrs ))
case _ =>
readNext()
}
Run Code Online (Sandbox Code Playgroud)
在这里,我有4个可能的属性,使用第2和第3个 - "Product"和attrs.
我们假设EvelementStart有20个参数.
然后,我要提到"_"占位的19倍,如果我想用/检查/匹配只有第一,或仅第二个值/参数?
如何scala specs 2在eclipse(scala-ide)中运行?
我的步骤是:
- sbt eclipse - 从现有源生成eclipse项目
- eclise:import project - 在eclipse ide中打开项目
- 在我的SPECS 2测试中放入断点(MyTest扩展规范{...)
- 尝试运行测试...... ?(通常我是在IntelliJ IDEA中做的..但今天要检查eclipse如何在调试中运行
scala..)
string = str.replaceAll("\\W", " ")
Run Code Online (Sandbox Code Playgroud)
这将用""(空格)替换所有特殊字符.
但我尝试将短划线" - "排除为特殊字符.
这是我的尝试:
string = str.replaceAll("\\W[^-]", " ")
Run Code Online (Sandbox Code Playgroud)
但这不是我所期待的.
问:我该如何工作?
我已经读过这个简单的回答了.
但是,如果我有对象列表但不仅仅是字符串:
case class Article(
title:String,
description:String,
examples: List[Example]
)
Run Code Online (Sandbox Code Playgroud)
有案例类示例:
case class Example(meaning:String, proofs:List[String])
Run Code Online (Sandbox Code Playgroud)
然后我如何将我的文章转换为json字符串?
如果我使用:
def article(word:String) = Action {
implicit val articleFormat = Json.format[Article]
implicit val exampleFormat = Json.format[Example]
val article = Article.article(word)
Ok( Json.format(article) )
// or: ?
Ok( Json.obj("examples" -> article.examples) ) // this works but only for Examples alone.. without Article
// or: ?
Ok( Json.obj("article" -> article) )
// or:?
Ok(
Json.toJson( // works, but it is still not that I'm …Run Code Online (Sandbox Code Playgroud) 我和Scala之间存在一些误解
0还是1?
object Fun extends App {
def foo(list:List[Int], count:Int = 0): Int = {
if (list.isEmpty) { // when this is true
return 1 // and we are about to return 1, the code goes to the next line
}
foo(list.tail, count + 1) // I know I do not use "return here" ...
count
}
val result = foo( List(1,2,3) )
println ( result ) // 0
}
Run Code Online (Sandbox Code Playgroud)
---编辑:
如果我return在这里使用它会工作"return foo(list.tail, count …
System.setProperty("webdriver.chrome.driver", "/usr/bin/google-chrome");
final ChromeOptions chromeOptions = new ChromeOptions();
//chromeOptions.addArguments("headless");
chromeOptions.addArguments("window-size=1200x600");
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
final URL url = new URL("https://the-internet.herokuapp.com/login");
final WebDriver driver = new RemoteWebDriver(url, desiredCapabilities);
Run Code Online (Sandbox Code Playgroud)
失败为:
线程“main” org.openqa.selenium.WebDriverException 中的异常:无法解析远程响应:
未找到
知道为什么吗?
在访问域时,我确实使用index.html和test.html以及看到的内容设置了Google Cloud Storage Bucket:
参见:doc.s3.amazonaws.com/2006-03-01,其中:
<?xml version='1.0' encoding='UTF-8'?>
<ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'>
<Name>my-domain.com</Name>
<Prefix></Prefix>
<Marker></Marker>
<IsTruncated>false</IsTruncated>
<Contents><Key>index.html</Key>
<Generation>1555969892676799</Generation>
<MetaGeneration>1</MetaGeneration>
<LastModified>2019-04-22T21:51...</LastModified>
<ETag>"...."</ETag>
<Size>25</Size></Contents><Contents>
<Key>test.html</Key>
Run Code Online (Sandbox Code Playgroud)
等等..
我没有亚马逊帐户。
org.springframework.cache.annotation.@CacheableQuarkus 有开箱即用的东西吗?(在文档中找不到任何提及)
放在某种服务方法上,
这将保留/缓存上一个响应一段时间并保留调用堆栈/日志。
类似于 Spring 的@Cacheable注解?