typing

Python 3.5 Typing ABCMeta does not define '__getitem__'

匆匆过客 提交于 2019-12-07 08:18:55
问题 I am trying out Python 3.5's typing module by marking up a few of my functions. I have a function that returns a list though I am getting a warning in PyCharm. The warning reads: Class 'ABCMeta' does not define '__getitem__', so the '[]' operator cannot be used on its instances from typing import List def get_list() -> List[int]: return [1, 2, 3] Is anyone able to better interpret that message then I can? Thanks 回答1: Was a bug in PyCharm. Resolved in 5.0.3. REF: https://youtrack.jetbrains.com

How can I pass `this` to a constructor without circular references (or losing type) in c++?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 21:46:37
EDIT: this has been marked as a duplicate. I believe there is a distinction between Q: what can I use to solve my problem, A: this thing ~and~ Q: what is this thing? A: big huge in depth answer. I'm not sure what the official ruling on this is though. I have two classes which both need to know about each other // Creator.h #pragma once #include "Creation.h" class Creator { Creator() { myThing = new Creation(*this); } int age = 42; Creation myThing*; } . // Creation.h #pragma once #include "Creator.h" class Creation { Creation(Creator &whoMadeMe) { std::cout << whoMadeMe.age; } } The issue is

Does Scala have a value restriction like ML, if not then why?

强颜欢笑 提交于 2019-12-06 21:35:33
Here’s my thoughts on the question. Can anyone confirm, deny, or elaborate? I wrote : Scala doesn’t unify covariant List[A] with a GLB ⊤ assigned to List[Int] , bcz afaics in subtyping “biunification” the direction of assignment matters. Thus None must have type Option[⊥] (i.e. Option[Nothing] ), ditto Nil type List[Nothing] which can’t accept assignment from an Option[Int] or List[Int] respectively. So the value restriction problem originates from directionless unification and global biunification was thought to be undecidable until the recent research linked above. You may wish to view the

F#, Nominative or Structural Typed

岁酱吖の 提交于 2019-12-06 20:20:31
问题 Does F# have a Nominative Type System or a Structural Type System? I know that OCaml is structurally typed, though F# doesn't seems to be so, is this correct? 回答1: F# is nominative. You can do a few structural tricks via some exotic mechanisms, but the type system of the language is primarily nominative. 来源: https://stackoverflow.com/questions/3137512/f-nominative-or-structural-typed

Untyped / typeless parameters in Delphi

半腔热情 提交于 2019-12-06 19:34:41
问题 What type are parameters without type like in the class TStringStream: function Read(var Buffer; Count: Longint): Longint; override; What is the type of Buffer parameter (is it a type of Pointer ?). 回答1: I wrote an article about this very topic a few years ago: What is an untyped parameter? Untyped parameters are used in a few situations; the TStream.Read method you ask about most closely matches with the Move procedure I wrote about. Here's an excerpt: procedure Move(const Source; var Dest;

Jquery with Typescript : Property 'css' does not exist on type 'ElementFinder'

不打扰是莪最后的温柔 提交于 2019-12-06 13:08:43
问题 I'm trying to use jquery in my angular2 project which is getting build with webpack . I got the webpack angular2 starter kit from here : here However ,I can't figure out how to get rid of these errors as my build is failing because of them . This is my typings.json { "globalDependencies": { "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", "angular2-beta-to-rc-alias": "file:./node_modules/@angularclass/angular2-beta-to-rc-alias/src/beta-17/typings.d.ts", "core-js":

“virtual” method's return type in objective-c

*爱你&永不变心* 提交于 2019-12-06 08:10:24
I have a class which is supposed to be abstract. In one of it's abstract methods the return type may be an instance of class1,class2 or class3, depending on the class that's implementing the method. I'm wondering how should I declare the method in the abstract class. I thought about using dynamic typing, but I want the return type to be restricted to one of the 3 classes, not every type, and in addition I'm not sure I can override it so that in the inheriting class the return type will not match the return type in the abstract class. I'd be glad if you could help me with this, Tnx! Take a look

Python 3.5 Typing ABCMeta does not define '__getitem__'

寵の児 提交于 2019-12-05 16:23:10
I am trying out Python 3.5's typing module by marking up a few of my functions. I have a function that returns a list though I am getting a warning in PyCharm. The warning reads: Class 'ABCMeta' does not define '__getitem__', so the '[]' operator cannot be used on its instances from typing import List def get_list() -> List[int]: return [1, 2, 3] Is anyone able to better interpret that message then I can? Thanks Was a bug in PyCharm. Resolved in 5.0.3. REF: https://youtrack.jetbrains.com/issueMobile/PY-17841 来源: https://stackoverflow.com/questions/34032272/python-3-5-typing-abcmeta-does-not

What are the conventions for types in Ruby?

坚强是说给别人听的谎言 提交于 2019-12-05 15:26:43
Being that Ruby is a language with purely dynamic types, I'm never quite sure what level of expectation I should have for the types passed to my methods. For example, if my method only functions when passed an Integer, should I be actively checking to make sure that's the case or should I just allow a type exception in such a case? Additionally, when it comes to writing design documents around Ruby code, what would be the proper way to specify what types a method should operate on? Javadocs (though not typically used for design documents) for example specify exactly what types a method will

Knowing if a Scala object is an instance of Case Class

有些话、适合烂在心里 提交于 2019-12-05 12:10:31
I was wondering if there as a way to know if an object is an instance of a case class. I was trying to find some structural type matching unapply , I notice they inherit Product . My real need for a function that would go something like: def withCaseClass[T <: /* matcher for case class */](obj:T) ... My major interest is to make sure only case classes can be passed to this function. A case class is an implementation detail. One can create a class that acts exactly like a case class -- and the ability to do so is a very important thing, as it ensures one can switch to a normal class if some