I keep getting this error [closed] - actionscript-3

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Implicit coercion of a value with static type object to a possibly unrelated number type
but iv defined it in
private var width:Object;
public function SetEnemyStartPosition():void
{
var stage:Object;
this.x = stage.stageWidth * .2 - (this.width * .2);

You've created a variable of the generic type Object, but you're treating it as a number.
From the code provided, it doesn't seem like you ever set a value to the variable width which makes the:
(this.width * .2)
part of your code wrong, it is null, and of the wrong type to do arithmetic operations on to begin with. I'd suggest changing the variable declaration to this:
private var width:Number;
and making sure width isn't null before you start using it.

Related

ES6 How to process string interpolation if the function is returned after the string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I have a function that returns an interpolated string for example.
`This is my string $t(some.value)`
The issue I am facing is that t is returned after I get the interpolated string. For example
const mainFunction = (targetString) => {
const { t } = getTranslationService();
return targetString;
}
I want to resolve the value and return the processed string in the mainFunction. I tried with eval but it didn't work
The answer in case it is useful for someone else
My first assumption was wrong, the function t is async.
The second was it was more complex than I expected, I needed to create a locale folder with a file en-US.json since how it works and all these it is relying on i18n
Finally, the target string should be in the JSON file. the t function will call a key from the JSON file and the targetString (enclosed between curly braces) will be translated. All this works in an asynchronic way.
you can do:
`This is my string ${t(some.value)}`
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Is good practice to use exceptions for logic? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I've got this example:
try {
images = this.getFinderFiles(path);
} catch (DirectoryNotFoundException exception) {
return [];
}
There is something wrong with this code?
I would recommend not to use exception handling for expected error situations. Exception handling takes time, stack unwinding has to be done.
In your case, if you usually can expect that 'path' usually exists and therefore the method can return a decent result - so you do not expect that 'this.getFinderFiles' fails - then it is fine to use exceptions here. But otherwise test the path for existence first before calling 'getFinderFiles'. That should be faster and for my taste more readable.
Btw. can you check the existence of 'path' within 'getFinderFiles' and eventually return '[]' already there?

What does "Save Value into the Parameters of a Method" Mean (Classes in C++) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I've got an assignment that is due tomorrow..
I don't want the entire solution, there's just a part of the program that i dont understand.
It's highlighted in the image below:
(I dont know what "save the values into the parameters of a method" means)
As you can see the type of the parameters is double& which means you are storing the values within the arguments you are sending. e.g, if you have 3 doubles a,b & c, when you call getAll(a,b,c) the result should be stored in them.
You can find more detailed explanation about &(reference) operator in
What does '&' do in a C++ declaration? .

Angular 7 correct way to check if JSON parse returns a specific object [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I'm a little confused about this.
I have a server returning a JSON string that represents an array of custom objects that I have defined. I need to perform some tests and check if each element of this array can be correctly cast/parsed to my object.
What is the correct way to do this?
I thought about creating a new Object and passing my JSON.parse(element) result to the constructor, but then how do I check if it was correctly created? Does it throw an exception?
Here is the simple way to check it:
checkJsonObject(string) {
try {
JSON.parse(string);
} catch (e) {
return false;
}
return true;
}

AssertTrue vs AssertEquals for ints [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Should we use assertEquals or assertTrue for comparing primitive types specifically ints?
Is there a preference, if so why ? I'd like to know the pros and cons of each approach.
assertEquals() gives a useful default error message on failure, like "expected X but got Y", but assertTrue() can't. Use the more specific applicable method here, which is assertEquals().
assertEquals() is to test the equality of your expected value with the returning value. Whereas assertTrue() is to check for a condition. Having said that, you can also say
If you have a condition like.
String x = "abc";
String y = "abc";
assertEquals(x, y);
You can also change it to
assertTrue(x.equals(y));
It is just another way of asserting what you expect.