English 中文(简体)
什么是将经营者定义为在Schala的一种方法的最短语?
原标题:What is the shortest notation to define an operator as a method alias in Scala?

Given the generic register method below I would like to define the := operator as a symbolic alias.

def register[Prop <: Property[_]](prop: Prop): Prop

@inline
final def :=[Prop <: Property[_]] = register[Prop] _

最初,我想写这样的话:

val := = register _

但是,这给我带来了职能签名Nothing => no。 我的下一个尝试是将其与“<代码>Prop”的类型联系起来,但显然只有在我将其编为“代码>def

Ideally I would like to omit the @inline annotation but I am not sure what object code the Scala compiler makes out of it.

www.un.org/Depts/DGACM/index_spanish.htm 最重要的是我的目标,是不要有<条码>:=方法重复<条码>所有部分的签字,但名称除外,然后简单地让前代表到后者。

问题回答
def :=[Prop <: Property[_]](prop: Prop) = register(prop)

should work.

我不认为,在目前情况下,在Schala实现你在座标(使你在Ruby)。 autoproxy plugin是解决这类问题的一种尝试,但是由于在汇编纸浆中产生编码存在各种问题,它并未真正准备好用于生产。

你可以这样做:

def := : Prop => Prop = register

因此,基本上在此,你界定了仅提及另一职能的类型(Prop=> Prop)。





相关问题
Python: Binding method

In following example I am trying to bind a method object via types.MethodType(...). It does not seem to work. Any suggestions? Thanks in advance. import types class Base: def payload(self, *args)...

Invoking an instance method without invoking constructor

Let s say I have the following class which I am not allowed to change: public class C { public C() { CreateSideEffects(); } public void M() { DoSomethingUseful(); } } and I have to call M ...

Behaviour of final static method

I have been playing around with modifiers with static method and came across a weird behaviour. As we know, static methods cannot be overridden, as they are associated with class rather than instance....

Setting the Page-Title in .Net using C# from a Class

Question, How do i set the title of a page from a class. Is it even possible? I can and have set the page title from a page itself and a usercontrol. Can I, How Do I do this via a class using C# ....

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签