例如,如果我有这个代码:
class a {
function __construct() {
echo "hello";
}
class b extends a{
function __construct() {
echo "world";
}
}
Run Code Online (Sandbox Code Playgroud)
我希望它输出"Hello World".相反,A类构造函数被B类构造器覆盖,因此仅输出"world".
这是我的代码:
foo :: Int -> IO()
foo a
| a > 100 = putStr ""
| otherwise = putStrLn "YES!!!"
Run Code Online (Sandbox Code Playgroud)
该功能应输出"YES !!!" 如果它小于100并且如果它大于100则不输出任何内容.虽然上面有效,但除了打印空字符串之外,还有更正式的方法来返回任何内容.例如
foo :: Int -> IO()
foo a
| a > 100 = Nothing
| otherwise = putStrLn "YES!!!"
Run Code Online (Sandbox Code Playgroud) 我很困惑何时使用ntohs和ntohl.我知道你在uint16_t和ntohl uint32_t使用ntohs的时候.但是那些使用unsigned int或者指定了特定位数的那些(例如u_int16_t doff:4;).
这是我的工作代码来说明问题:
// Utility/Debugging method for dumping raw packet data
void dump(const unsigned char *data, int length) {
unsigned int i;
static unsigned long pcount = 0;
// Decode Packet Header
struct ether_header *eth_header = (struct ether_header *) data;
printf("\n\n === PACKET %ld HEADER ===\n", pcount);
printf("\nSource MAC: ");
for (i = 0; i < 6; ++i) {
printf("%02x", eth_header->ether_shost[i]);
if (i < 5) {
printf(":");
}
}
printf("\nDestination MAC: ");
unsigned short ethernet_type = ntohs(eth_header->ether_type);
printf("\nType: …Run Code Online (Sandbox Code Playgroud) 我有2个数组,y及z
欲返回一个整数数组,其中result[i] = y[i] - z[i]
这是代码:
static int[] join(int[] y, int[] z) {
int[] result = new int[Math.min(y.length, z.length)];
for(int i = 0; i < result.length; ++i) {
result[i] = y[i] - z[i];
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但是我想使用Java的8种函数式编程技术(如流)来做同样的事情.但是我知道的所有流函数一次只能用于一个列表.
我怎样才能做到这一点?
编辑
另外我怎么能做我提到的相同的事情,但我想返回一个布尔数组,其中:result[i] = y[i] == 5 || z[i] == 10
当试图查找created_at时间大于某个值的所有记录时,它似乎不起作用。
例如我已经尝试过这个:
return Foo::where('created_at', '>', '1457408361')->get();
Run Code Online (Sandbox Code Playgroud)
但它不断返回所有记录!
我正在使用Guzzle 6。
我正在尝试模拟客户端并像这样使用它:
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
$mock_handler = new MockHandler([
new Response(200, ['Content-Type' => 'application/json'], 'foo'),
]);
$history = [];
$history_middleware = Middleware::history($history);
$handler_stack = HandlerStack::create($mock_handler);
$handler_stack->push($history_middleware);
$mock_client = new Client(['handler' => $handler_stack]);
// Use mock client in some way
$mock_client->get("http://example.com", [
'query' => [
'bar' => '10',
'hello' => '20'
],
]);
// ------
// get original request using history
$transaction = $history[0];
/** @var Request $request */
$request …Run Code Online (Sandbox Code Playgroud) 在其他数据库(如 MySQL)中,我可以这样做:
ALTER TABLE demo RENAME INDEX old_index TO new_index
Run Code Online (Sandbox Code Playgroud)
SQLite 的最佳解决方法是什么?
更新
SQLite 似乎不支持这种语法。在这种情况下,我可以使用解决方法。例如:
DROP INDEX old_index;
CREATE INDEX new_index ON demo(col1, col2);
Run Code Online (Sandbox Code Playgroud)
上面的问题是我需要手动找出哪些列被索引。我想要一些可以自动完成的事情,比如:
set columns = select columns indexed by old_index;
DROP INDEX old_index;
CREATE INDEX new_index ON demo(columns);
Run Code Online (Sandbox Code Playgroud) 以下填充整个屏幕:
<View height="Ti.UI.FILL" width="Ti.UI.FILL">...</View>
Run Code Online (Sandbox Code Playgroud)
fill属性在这里描述:http://docs.appcelerator.com/platform/latest/#!/ api/Titanium.UI- property- FILL
但是你也可以使用以下方法做同样的事情:
<View height="100%" width="100%">...</View>
Run Code Online (Sandbox Code Playgroud)
因此我的问题是,有什么区别?
titanium appcelerator titanium-alloy appcelerator-titanium appcelerator-alloy
我希望执行以下操作:
let $foo :=
if (5 = 5)
then
return <bye/>
else
return <hi/>
Run Code Online (Sandbox Code Playgroud)
但不幸的是,上述方法不起作用。
如果语句用于 let 语句,我该怎么做。
我正在Windows上运行Homestead v8.0.1的新版本。
我的Homestead.yml文件看起来像这样:
---
ip: "192.168.99.20"
memory: 2048
cpus: 1
provider: virtualbox
backup: true
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Documents/example
to: /home/vagrant/code/dealer-app
sites:
- map: example.test
to: /home/vagrant/code/example/public
type: "apache"
databases:
- example
ports:
- send: 4200
to: 4200
- send: 49153
to: 49153
Run Code Online (Sandbox Code Playgroud)
我做了以下工作:
$ git clone https://github.com/laravel/homestead.git .
$ git checkout v8.0.1
$ init.bat
$ vagrant up
Run Code Online (Sandbox Code Playgroud)
在我收到此错误之前,大多数方法都有效:
homestead-7: Running: script: Update Composer
homestead-7: Updating to version 1.8.2 (stable channel).
homestead-7:
homestead-7:
homestead-7: [ErrorException]
homestead-7: …Run Code Online (Sandbox Code Playgroud)