我得到" Elixir编译错误:带有多个子句和默认值的定义需要标题。"对于以下功能。我不明白我为什么会错误地收到这个错误?关于如何解决它的任何建议?
#import "LoadPresentViewController.h"
#import "WebViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)doLoadPresent:(id)sender {
WebViewController *wvc = [[WebViewController alloc]init];
[self presentViewController:wvc animated:NO completion:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
// this fails in viewDidLoad
// WebViewController *wvc = [[WebViewController alloc]init];
// [self presentViewController:wvc animated:NO completion:nil];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// this succeeds in viewDidAppear
WebViewController *wvc = [[WebViewController alloc]init];
[self presentViewController:wvc animated:NO completion:nil];
}
@end
错误讯息:
def stream(query, opts \\ []) do
initial_key = Keyword.get(opts, :initial_key, 0)
key_name = Keyword.get(opts, :key_name, :id)
chunk_size = Keyword.get(opts, :chunk_size, 500)
Stream.resource(fn -> {query, initial_key} end,
fn {query, last_seen_key} ->
results = query
|> Ecto.Query.where([r], field(r, ^key_name) > ^last_seen_key)
|> Ecto.Query.limit(^chunk_size)
|> __ENV__.module.all
case List.last(results) do
%{^key_name => last_key} ->
{results, {query, last_key}}
nil ->
{:halt, {query, last_seen_key}}
end
end,
fn _ -> [] end)
end
答案 0 :(得分:1)
当你stream/2
时,Ecto已经定义了一个名为use Ecto.Repo, otp_app: :my_app
的函数。你将需要将你的功能称为别的东西。