Scalatra文件组织(Scalatra file organisation)
我应该如何在Scalatra中管理我的文件。 遇到以下错误后,我对Scala中“代码分离”的基本理解已被破坏。
在Scalatra中工作我在一个文件中定义了一个类,并在尝试在另一个文件中定义具有相同名称的类后收到错误。 我对这个错误感到有些困惑,因为我的印象是每个文件都有一定程度的隔离(Node JS启发的假设)。
我现在正在开发一个需要的应用程序:Actors,Routes,Classes等。 我应该如何组织这些东西?
How should I manage my files in Scalatra . After encountering the following error my fundamental understanding of "code separation" in Scala has been destroyed .
Working in Scalatra I defined an class in one file and received an in an error after attempting to define a class with the same name in another file . I was somewhat confused about the error because I was working under the impression that there was some degree of isolation afforded to each file ( Node JS inspired assumption).
I cam currently working on an application that requires : Actors, Routes, Classes, etc . How should I organize these things ?
原文:https://stackoverflow.com/questions/27025785
最满意答案
你需要用逗号(
,
)分隔它们:例如
public static TResponse Search<TResponse, TRequest>(TRequest args) where TResponse : IBaseSearchArgs , IBaseSearchProps {...}
you'll need to separate them by a comma (
,
):e.g.
public static TResponse Search<TResponse, TRequest>(TRequest args) where TResponse : IBaseSearchArgs , IBaseSearchProps {...}
相关问答
更多-
EasyMock不支持这个功能,所以你被困在临时接口的回退中。 顺便说一下,我嗅到了一些代码wiff - 如果一个方法真的把对象当作两种不同的东西,在这种情况下是Foo和Closeable接口? 这意味着该方法正在执行多个操作,虽然我怀疑其中一个操作是“关闭” Closeable ,那么调用代码决定是否需要“close”是否更有意义? 通过这种方式构造代码,可以在同一个try ... finally块中保持'open'和'close',并且恕我直言使代码更具可读性,更不用说更通用的方法,并允许您传递仅实现F ...
-
做一个新的界面 public interface IAandB extends IA, IB 并且使FooA和FooB实现它。 Do a new interface public interface IAandB extends IA, IB and make FooA and FooB implement it instead.
-
如果要强制执行编译时限制, A和I都是传入的指针的基类,则可以使用std::enable_if和std::is_base_of : template
typename std::enable_if< std::is_base_of::value && std::is_base_of::value >::type foo(T* t) { } 如果t指向一个继承自A和I的类,则foo将仅在重载决策集中。 这对您来说是否是一个好的解决方案取决于您是否想 ... -
如何在Java中要求一个方法参数来实现多个接口?(How can I require a method argument in Java to implement multiple interfaces?)[2023-02-17]
你可以用泛型: publicvoid spew(T t){ t.append("Bleah!\n"); if (timeToClose()) t.close(); } 实际上你的语法是对的。 You could do it with generics: public void spew(T t){ t.append("Blea ... -
应该将equals()实现到哪个接口? 只有一个等于重要,这是 public boolean equals(Object other) 这里没有界面。 你怎么知道实现接口的类是否已经对你正在使用的接口实现了equals()? 你必须说哪个类是等于的,如果有疑问,只有同一个类是相等的,没有其他类。 我想检查两个有色物体是否相等, 那么一只红狗与红椅子相同而且相同? 那有意义吗? 如果要进行排序,通常会根据类的字段进行排序。 例如 List
colours = ... colours.s ... -
你需要用逗号( , )分隔它们: 例如 public static TResponse Search
(TRequest args) where TResponse : IBaseSearchArgs , IBaseSearchProps {...} you'll need to separate them by a comma (,): e.g. public static TResponse Search (TReques ... -
不可以。您可以将Java中的接口视为合同。 因为这些接口具有相同的方法名称(但返回类型不同),所以没有一个类可以同时满足这两个合同。 如果他们有不同的论点,答案会是肯定的。 No. You can think of interfaces in Java as contracts. Because these interfaces have the same method name (but different return types) no one class can fulfil both contra ...
-
检查方法是否实现了用attribute标记的接口方法(Check if method implements interface method marked with attribute)[2023-09-12]
是的,可以找出方法是否是接口方法的实现。 这是执行此操作的代码: methodSymbol.ContainingType .AllInterfaces .SelectMany(@interface => @interface.GetMembers().OfType()) .Any(method => methodSymbol.Equals(methodSymbol.ContainingType.FindImplementationForInterfa ... -
为什么不使用以下内容: public static bool ImplementsAny(this object obj, params Type[] types) { foreach(var type in types) { if(type.IsAssignableFrom(obj.GetType()) return true; } return false; } 然后你可以这样称呼它: model.ImplementsAny(t ...
-
一般意义上没有真正的解决方案,但对于您的特定示例,您可以尝试以下方法: public
void foo(A bar) { // ... } private interface A { Object work(final Fizz fizz, final T t); } private interface B extends A { default Object work(final Fizz fizz) { return work ...