I am kinda new and tried searching for my answer extensively. Thing is I am getting compile errors which I have no clue why it is.
Example code:
let request: NSFetchRequest<DeelnemersBestand> = DeelnemersBestand.fetchRequest()
DeelnemersBestand is a managedObject (press option button and hover over DeelnemersBestand) and an Entity in my CoreData. I have stated the import CoreData and so on.
Similar code I used in other places in the same code (other classes) as well. Without any errors.
Here comes the strange part. In this class I got a compile error
Cannot convert value of type 'NSFetchRequest<NSFetchRequestResult>' to specified type 'NSFetchRequest<DeelnemersBestand>
So I need to cast it as follows to get rid of the error.
as! NSFetchRequest<DeelnemersBestand>
Strange thing is that similar code I use in other classes as well but there I don't get that error.
It puzzles me, anybody any idea what could make it different?
Related
I've come up against an odd issue in Eclipse while using the Stanford CoreNLP API. I've written a custom implementation of the Annotator interface, which amongst other things specifies two methods with the type signature Set<Class<? extends CoreAnnotation>>.
I've implemented those methods, but Eclipse is showing an error telling me that the type signature is incorrect. Specifically, it reports, The return type is incompatible with Annotator.requires(). The recommended fix suggests changing the return type to exactly the same type I already have written, but still leaves the error:
As you can see, the supposed `incorrect' type is exactly the same as the type given in the interface.
The project compiles correctly using mvn compile, so this isn't an actual compiler problem. Has anyone seen this before, and can you advise as to how to make those errors go away?
Edit: added screenshot showing the error
Edit2: added details of the error message in Eclipse
I'm writing a little program in scala that would simulate a doctors practice. One of the requirements is that a user can set consultations with a doctor. I have implemented a solution that gives you the consultation object if you succeed and also prints a message saying that the action was successful.
This is where a little "bug" (more a minor but annoying inconveniece) appears. When I tell my scala worksheet to make a new variable like so:
var consultation: Consultation = patient.makeConsultation(x, y, z)
Well this works perfectly BUT the message that it should print is printed at the top of the output window and not at the point in the worksheet were the variable is actually created. Does anyone know a solution for this?
Thanks in advance.
This is not a bug but the expected behaviour. The println in your makeConsultation function is a side-effect which has nothing to do with the creation of Consultation.
You can use Scala's type system (check Option or Try) to represent that makeConsultation could fail.
An error in my code that I frequently encounter is using a wrapped string while formatting. Especially around rules changing in Swift between versions it causes subtle bugs that aren't obvious by reading the code alone until I really look into the resulting string. It looks something like:
let myPostURL = "some/url/\(anObject.anID)"
Which then leads to:
"some/url/Optional(123)"
It's completely undesirable to see this, only a crash would be worse. Is there a way to let the compiler throw a warning or error every time this happens?
In the latest versions of Swift, there is a warning for this:
This was implemented in https://github.com/apple/swift/pull/5110 and https://github.com/apple/swift/pull/5195.
I'm using the current version of the TypeSafe Scala/eclipse IDE. I have an object (which I called PositionObj to give it a unique name). PositionObj contains a main method. Yet when I try Run as > Scala application I get a pop-up message saying:
PositionObj needs to be an 'object' (it is currently a 'class').
In fact it's not a class, and there is no class with that name. Any thoughts about why this is happening and how I can get around it?
Here is the relevant code.
object PositionObj { ...
def main(args: Array[String] = Array[String]()): Unit = {
// This is just to see if anything happens.
println(position(3).p1Rqmts.keys.head)
}
...
Thanks.
Based on your answered-to code, try removing the default argument, since this might be creating a different code signature
I should have done this before, but now I notice that there is a compiler error message that says that the compiler couldn't handle the code because it was too big for a method. That's consistent with my experience with the problem. When I comment out a large table of data, everything works fine. So I'm now convinced that the problem was simply that the program was organized in a way that pieces of it were too large to be handled by the compiler.
I got around the problem by chopping my data table into multiple parts and including each one in a separate object. That worked even though all the objects were then included in the overall program. It was not the size of the program overall; it was the size of large chunks.
The compiler error message was somewhat misleading in that it said the problem was that a method was too large. In fact, my data table was a val in an object and not within a method. But as I said, chopping it up into separate objects and combing them with software solved the problem.
I'm trying to use smarttabs.el from https://gist.github.com/188961 in latest emacs-dev (bzr). When trying to compile or load it I get the error:
smarttabs.el:54:1:Error: Don't know how to make a localized variable an alias
which is completely new to me. How do I correct this?
Also see http://www.emacswiki.org/emacs/SmartTabs for package explanation.
The error message is trying to say that defvaralias (used in the smart-tabs-advice macro) doesn't do what jacius thinks it does. But I'm not quite sure what he thinks it does, so I'm not sure how to fix it. Try reporting the error to him.