Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
TheBrickAdmin's user avatar
-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 ...
Ric1304's user avatar
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:...
Alireza Ahmadi's user avatar
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 { ... } ...
Guillaume PELOUAS's user avatar
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 ...
johnny2's user avatar
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 ...
EtienneBonnafoux's user avatar
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 ...
Abduweli Abdiaziz's user avatar
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,...
aardwolf's user avatar
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 ...
Daniel's user avatar
  • 7,645
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 ...
Zak's user avatar
  • 12.5k
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 (...
wlnirvana's user avatar
  • 2,007
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; ...
Taylor Brown's user avatar
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&...
MK.'s user avatar
  • 34.2k
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&...
Hassan Htait's user avatar
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 ...
Jay Dee's user avatar

15 30 50 per page
1
2 3 4 5
81