literals Questions

7

Solved

I want to convert below string to an array in javascript. {a:12, b:c, foo:bar} How do I convert this string into array of objects? Any cool idea?
Zoroaster asked 13/8, 2010 at 3:13

1

Solved

I want to restrict the possible input arguments by using typing.Literal. The following code works just fine, however, mypy is complaining. from typing import Literal def literal_func(string_input...
Bailee asked 24/11, 2022 at 8:24

2

Solved

How can I get the literal value out of a Literal[] from typing? from typing import Literal, Union Add = Literal['add'] Multiply = Literal['mul'] Action = Union[Add,Multiply] def do(a: Action): ...
Postbellum asked 3/12, 2019 at 18:50

7

Solved

Given an array of pointers to string literals: char *textMessages[] = { "Small text message", "Slightly larger text message", "A really large text message that " "is spread over multiple lines...
Konstance asked 22/9, 2012 at 7:28

2

Solved

I have been able to use the digit-separator ' in my C projects thus far. They have all been compiled with the MSVC compiler with no problems. I have just changed to using the GCC compiler instead,...
Footcloth asked 26/6, 2016 at 15:13

10

Solved

In short, if you want to write a map of e.g. constants in Java, which in e.g. Python and Javascript you would write as a literal, T<String,String> CONSTANTS = { "CONSTANT_NAME_0": CONSTANT...
Aufmann asked 26/9, 2010 at 13:52

3

Solved

I need to check if object is descendant of typing.Literal, I have annotation like this: GameState: Literal['start', 'stop'] And I need to check GameState annotation type: def parse_values(ann) if...
Gonocyte asked 19/1, 2022 at 13:20

2

Solved

I have a raw string literal which is very long. Is it possible to split this across multiple lines without adding newline characters to the string? file.write(r#"This is an example of a line which...
Aubreyaubrie asked 19/8, 2016 at 0:5

1

Consider a piece of code below. Is there an integer literal that would compile on both 32-bit and 64-bit platforms? #include <iostream> #include <cstdint> void f(double) { std::cout &...
Nyala asked 31/5, 2022 at 18:52

2

Solved

I know the variables in function are using stack space. When function exit, the space are freed. That's why we should declare the pointer variable as static in function. However, I found that the c...
Thorsten asked 5/5, 2022 at 9:44

4

Solved

Regular float literals do not work: extern crate num_traits; use num_traits::float::Float; fn scale_float<T: Float>(x: T) -> T { x * 0.54 } fn main() { let a: f64 = scale_float(1.23)...
Gannet asked 8/6, 2018 at 20:22

5

Solved

In C/C#/etc. you can tell the compiler that a literal number is not what it appears to be (ie., float instead of double, unsigned long instead of int): var d = 1.0; // double var f = 1.0f; // float...
Sanctus asked 28/4, 2011 at 15:3

1

Solved

I'm trying to refactor an old C++ code. At some point I've something like: #if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) # define I64_CONST(X) X ## i64 #else # define...
Norling asked 25/1, 2022 at 15:7

3

Solved

I'm looking at the numeric types in Go. I want to use uint64 literals. Is this possible in Go? Here's an example of how I'd like to use uint64 literals: for i := 2; i <= k; i += 1 { // I want ...
Oubre asked 19/12, 2015 at 22:41

1

Solved

Taking the first steps with <chrono> library, I'm starting with basic arithmetic on a days grained time_point. Thanks to a very useful post by @HowardHinnant, I managed to write this: #includ...
Flavourful asked 11/1, 2022 at 9:33

5

Solved

In my actual project It happened accidentally here is my modified small program. I can't figure out why it is giving output 10? public class Int { public static void main(String args[]) { int ...
Kling asked 13/4, 2014 at 6:25

3

Solved

I use type hints with pydantic to set return schema for my Python API. I would like to write a literal type that allows the numbers 0 to 100. This is easy typing it out manually: from typing import...
Permanence asked 24/3, 2021 at 16:22

3

I want to combine both having a type for a constant, and using it "as const" to get the literal types as the type: type MyType = {name: string}; const x:MyType = { name: 'test' // Autoc...
Desorb asked 20/6, 2019 at 21:26

4

Solved

The program #include <stdio.h> int main(void) { printf("sizeof( char ) = %zu, sizeof 'a' = %zu.\n", sizeof( char ), sizeof 'a' ); return 0; } outputs the following: sizeof(...
Valine asked 2/11, 2021 at 13:0

2

Solved

I modified PowerShell script from PowerShell - Batch change files encoding To UTF-8. # Modified version of https://mcmap.net/q/244754/-powershell-batch-change-files-encoding-to-utf-8 [Threading.T...
Beauvais asked 2/9, 2019 at 10:32

4

Solved

Is LL defined anywhere in the standard (hard term to come by)? ideone accepts the code int main() { std::cout << sizeof(0LL) << std::endl; std::cout << sizeof(0); } and prin...
Palpitate asked 22/3, 2013 at 16:15

6

Solved

I ask because I am using the Box2D library, which calls for mostly float arguments. Although I see a lot of example code that uses the 0.00f format, I am not quite sure if there is an actual differ...
Callus asked 8/10, 2011 at 13:34

3

Solved

Is there a multiline string literal syntax in Matlab or is it necessary to concatenate multiple lines? I found the verbatim package, but it only works in an m-file or function and not interactivel...
Cherin asked 9/1, 2013 at 11:9

3

Solved

Bug > Swift > Enum > String Protocol I was attempting to create an enumeration in which all its elements were file names, and I stumbled across something interesting. Like so: enum FileNa...
Ridotto asked 8/5, 2020 at 16:19

10

Solved

In PHP, I can specify array literals quite easily: array( array("name" => "John", "hobby" => "hiking"), array("name" => "Jane", "hobby" => "dancing"), ... ) But what if I wa...
Dot asked 10/3, 2012 at 7:54

© 2022 - 2025 — McMap. All rights reserved.