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 9 years ago.
Improve this question
I want for a variable to be 'name' for example. If I use read(x) and for that variable to be char it will only load the first letter. So if i type 'name' it would be only the first letter.
the word you refer to is actually called string, so you can declare a variable and read string in it:
var
msg:string[10];
begin
readln(msg);
writeln(msg);
end.
Related
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 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
Is it possible to take a [...]string{} and then loop over each string to create a new variable where the variable name is the string?
I can do this using interpolation with some other languages, but I'm kind of a golang newbie.
Nope. Go provides no way to dynamically create variables.
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 2 years ago.
Improve this question
I want to define a new variable called : character , with type of character
How can i do that without errors? (despite they have the same name)
I tried this on paper : variable character: character, but i am not sure if its correct or not
Thanks.
It depends on your programming language. Like in java you use-
char character = 'A';
And in c-
char character;
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 5 years ago.
Improve this question
I'm trying to use a negative value in a string which is in a hash.
{"amount"=>"-50.01", "currency"=>"CAD"}
If I write transaction.amount I get 0.5001E2, if I use to_f I get 50.01.
I'm trying to extract the -50 value.
Thank you for your help!
Try
transaction['amount']
For example
a = {"amount"=>"-50.01", "currency"=>"CAD"}
Then
a['amount']
returns '-50.01'
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 6 years ago.
Improve this question
I'm working with a script that only takes integer values. I'm reading from a CSV with a timestamp example of 12:34. Is there a way I get ruby to read it as an integer?
Not sure if you are dealing with a Time object. If so:
str = Time.now.to_s[/\d\d:\d\d:\d\d/]
=> "19:04:53"
str.gsub(":", "").to_i
=> 190453
If it's a string just start with the sub:
"12:34".sub(":", "").to_i
=> 1234
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 9 years ago.
Improve this question
Is it possible to pass parameter to a method like this:
variable = my_method(:parameter)
No quotes, no nothing.Just -> :parameter .
Yes, you can pass a symbol to a method. Example:
puts('hello')
or
puts(:hello)