Questions tagged [string-to-symbol]

9 questions
6
votes
1 answer

Crystal language: what to use instead of runtime String::to_sym

I am trying to convert a Ruby program to Crystal. And I am stuck with missing string.to_sym I have a BIG XML file, which is too big to fit in memory. So parsing it all is out of question. Fortunately i do not need all information, only a portion of…
jsaak
  • 587
  • 4
  • 17
6
votes
4 answers

Ruby symbol setup

I was setting up symbols in my code like: "name_of_symbol".to_sym However, my principal engineer picked it up during code review as a bad practice and asked me to set symbols like: :"name_of_symbol" When I asked him why? He said it's bad…
Jakub Zak
  • 1,212
  • 6
  • 32
  • 53
2
votes
1 answer

To convert variable name to string or symbol

it's possible in rails convert variable name to string? Example: stack_overflow = "Fantastic!". by stack_overflow.to_sym I'll get :Fantastic!. Instead I would => :stack_overflow and, if it were possibile, this would be bad programming cause unsafe…
misterwolf
  • 424
  • 4
  • 14
2
votes
2 answers

How to get a property from a plist

I am a newbie in Lisp. I want to access a particular property from a property list with a string variable like this (setf sym (list :p1 1)) (setf x "p1") (getf sym :x)
emotionull
  • 595
  • 2
  • 8
  • 24
1
vote
3 answers

Is there an isdigit function (overload) which includes the negative symbol?

I'm trying to search for the beginning of a number. isdigit is there a c++ function that can include negatives in isdigit? So that it will match the first character of the number: "-13"?
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
1
vote
1 answer

Taking a key from a hash, and interpolate that as a getter on an object

I have a class that creates objects. I've created getter/setter methods for that class. Class Test attr_accessor :method1, :method2, :method3, :method4 I have created several instances from that class, and appended them to a list @object_array =…
ARL
  • 986
  • 2
  • 12
  • 25
0
votes
6 answers

Compare two hashes no matter symbols or strings, rails

I would like to compare two hashes and forces them to be equal: one with Symbols on keys and values the second with only strings. e.g: sym_hash = {:id=>58, :locale=>:"en-US"} string_hash = {"id"=>58, "locale"=>"en-US"} Try like this does not…
Kruupös
  • 5,097
  • 3
  • 27
  • 43
0
votes
1 answer

SAS IML use of Mattrib with Macro (symget) in a loop

In an IML proc I have several martices and several vectors with the names of columns: proc IML; mydata1 = {1 2 3, 2 3 4}; mydata2 = {1 2, 2 3}; names1 = {'red' 'green' 'blue'}; names2 = {'black' 'white'}; To assign column names to…
-1
votes
1 answer

String to symbols and numbers

Is there a way to turn the addition, subtraction, multiplication, and division symbols in a string to actual addition, subtraction, multiplication, and division symbols, along with the numbers inside the string to actual numbers? So, instead of the…
jessica
  • 1,667
  • 1
  • 17
  • 35