我是Objective C的新手并试图找出^运算符是什么?在探索一些源代码时,我看到了下一个构造:
dispatch_once(&onceToken, ^{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(20.f, 13.f), NO, 0.0f);
[[UIColor blackColor] setFill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 20, 1)] fill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 5, 20, 1)] fill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 10, 20, 1)] fill];
[[UIColor whiteColor] setFill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 1, 20, 2)] fill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 6, 20, 2)] fill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 11, 20, 2)] fill];
defaultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
});
Run Code Online (Sandbox Code Playgroud)
而且我想知道^是什么?
我正在尝试将参数POST到Action,并在路由中写道:
# Home page
GET / controllers.Application.index()
POST /login/name:/password: controllers.Application.login(name, password)
Run Code Online (Sandbox Code Playgroud)
我有一个动作
public static Result login(String name, String password) {
return ok(name + " " + password);
}
Run Code Online (Sandbox Code Playgroud)
我的表格是
<form action="/login" method="post">
<input name="name" type="text" id="name">
<input name="password" type="password" id="password">
<input type="submit" value="Login">
</form>
Run Code Online (Sandbox Code Playgroud)
它不起作用
如有要求 'POST /login' [Missing parameter: name]
我究竟做错了什么?
试图找出如何有效地在我的代码中使用新的Java 8特性.stream().
这是我的一般代码
List<Item> list = db.query(sqlStatement, (rs, i) -> new Item(rs));
Map<String, List<Item>> itemsByName = new HashMap<>();
for (Item m : list) {
if (!itemsByName.containsKey(m.getName())) {
ArrayList<Item> items = new ArrayList<>();
items.add(m);
itemsByName.put(m.getName(), items);
} else {
itemsByName.get(m.getName()).add(m);
}
}
Run Code Online (Sandbox Code Playgroud)
由此(1)
List<Item> list = db.query(sqlStatement, (rs, i) -> new Item(rs));
Run Code Online (Sandbox Code Playgroud)
我得到的项目列表看起来像:
list(0):Name1:Value1
list(1):Name1:Value2
list(2):Name2:Value1
list(3):Name3:Value3
由此(2)
Map<String, List<Item>> itemsByName = new HashMap<>();
for (Item m : list) {
if (!itemsByName.containsKey(m.getName())) {
ArrayList<Item> items = new ArrayList<>();
items.add(m);
itemsByName.put(m.getName(), items); …Run Code Online (Sandbox Code Playgroud) collections ×1
ios ×1
java ×1
java-8 ×1
java-stream ×1
lambda ×1
objective-c ×1
url-routing ×1