All Questions
1,209
questions
1
vote
1
answer
37
views
PowerShell - cast a variable type based on a variable definition
I've got a hashtable with variables. The source of this hashtable is an empty parameters.json (for deployment of Azure resources) converted to a hashtable.
For this question I have simplified this ...
-1
votes
0
answers
16
views
Tensorflow is not casting my tensor as type float64 when I want it to, how do I fix it?
It's basically in the title. I'm trying to cast a tensor as a float64 for extra precision and so it can match what the data type of my bias is. However, despite calling the tf.cast function, it's ...
1
vote
3
answers
185
views
Type 'string | boolean' is not assignable to type 'never' in typescript
Consider this class:
const creditRiskRatingKeys = [
'applicant_id',
'is_dirty',
] as const;
const dict = {
applicant_id: 'test_id',
is_dirty: true,
}
class CreditRiskRating {
applicant_id:...
0
votes
2
answers
64
views
func argument with an Array of mixed types (protocol), then call a static method of the protocol
Here are my structures (I can have lot more, that why I need a generic way to do with MyProtocol):
protocol MyCustomCodable {
static func buildQuery()
}
struct A: MyCustomCodable {
...
}
...
0
votes
1
answer
71
views
How to convert type to generic type, whose actual type is known at the point of conversion?
I have a set of methods which simply return a stored 'object' as a different type each, like this:
bool GetAsBool();
string GetAsString();
int GetAsInt();
In the real scenario, there are currently 16 ...
2
votes
1
answer
52
views
Are there good reason to accept float but not int in a function in Python?
In a big library, I had a 'bug' because a function which accept only float but not int
def foo(penalty: float):
if not isinstance(penalty, float):
raise ValueError(f"`penalty` has to be ...
0
votes
0
answers
28
views
What can I do when getting "type 'List<String>' is not a subtype of type 'String' in type cast" in flutter when i want to output list of values?
i have the error of "type 'List' is not a subtype of type 'String' in type cast" when ever i pass data of summary question widget to the result screen widget
i was expecting to view the ...
0
votes
1
answer
46
views
PostgreSQL - how to implement my own casting from text to numeric
I need to write casting from text to numeric to accept values in single brackets as negative.
Example:
'(15)'::numeric should return -15.
Creating a domain and writing a cast function would be perfect,...
0
votes
3
answers
103
views
Check if object of base class came from subclass [duplicate]
I have a base class and a bunch of subclasses of it.
I have an object of base class and I know that it was an instance of one of the subclasses before, but it was casted to the base class.
I want to ...
1
vote
2
answers
101
views
Similar types (`int16_t` and `short`) produce different behaviors during reference instantiation
I'm running into the following error depending on which type I choose for a variable.
/home/zak/Development/Arduino/generated_examples/ArduinoIoTCloud_Basic/thingProperties.h: In function 'void ...
0
votes
1
answer
45
views
Convertibility of different types to CustomDebugStringConvertible in Swift
I don't understand when will an upcast to CustomDebugStringConvertible succeed. In the following example, errorClass and myEnum don't compile. But what is causing the failure? Why the other two (...
0
votes
1
answer
54
views
Why can't a generic factory redirect to a specific subclass?
Below is some code that (currently) doesn't compile:
sealed class MyValue<ValueT> {
final ValueT value;
const MyValue(this.value);
const factory MyValue.bool(bool value) = MyBool;
...
0
votes
0
answers
31
views
understanding the difference between Wnarrowing and Wconversion [duplicate]
The following code in my opinion is a narrowing conversion:
#include <memory>
#include <iostream>
#include <math.h>
void f1(int32_t i) {
std::cout << i << "\n&...
0
votes
0
answers
37
views
Type casting, console giving wrong answer
I am running this code on VS for Python, I am inputting a number but it's giving me the same number without exponentiating it.
something = (anything ** 5.0)
print(anything, "to the power of 2 is&...
0
votes
0
answers
41
views
How do I narrow type with Typescript, considering, that it's a union type, and index is a variable?
actionsCollection has union type with similar structure:
{
install: {...}
bid: {...}
} | {
travel: {...}
bid: {...}
pass: {...}
} | ...
None of the keys in subsets are mandatory or unique.
Here's my ...