utf 8 - Error with If Statment in Liberty/ISE Eiffel -


i have problem if statment.

i have program commandline-arguments , utf8 (€ - symbol).

the error in works_not in if statement.

class euro  insert arguments  create {any}    make  feature {any}     make                works_not          works       end     works_not       local ok: boolean                print ("%n%nanzahl argumente          : " + argument_count.to_string + "%n")          print ("%nargument -> programmname    : " + argument(0))          print ("%nargument -> wert            : " + argument(1))          print ("%nargument -> währung         : " + argument(2) + "%n")           ok := argument(2) = "€"           print ("%nargument(2) ist euro ?  " + ok.to_string + "%n%n")           print ("don't work")          io.put_new_line           if argument(2) = "€"             euro_in_dm(argument(1).to_real)          else             dm_in_euro(argument(1).to_real)          end       end     works                print ("works ")          io.put_new_line           if argument_count /= 2             print("%n%n error (1) %n%n")              else             inspect                 argument(2)              when "€"                euro_in_dm(argument(1).to_real)             when "dm","dm"                dm_in_euro(argument(1).to_real)             else                print("%n%n error (2) %n%n")             end          end       end  feature     euro_in_dm (a: real)                io.put_string("%n euro -> dm ")          io.put_real(a * 1.95583)          io.put_string("%n%n")       end     dm_in_euro (a: real)                io.put_string("%n dm -> euro ")          io.put_real(a / 1.95583)          io.put_string("%n%n")       end  end 

the issue in comparison operator argument(2) = "€".

in eiffel strings have reference type, equality operator = compares references string objects, not contents. if want compare string values instead, need use operator ~ internally calls is_equal after checking types of both operands same, or more robust version same_string (provided available in version of environment). summarize, can try 1 of following instead of equality:

  • argument(2).same_string ("€")
  • argument(2) ~ "€"
  • argument(2).is_equal ("€")

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -