Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
unintuitive language feature (exclamation functions)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="F. Senault, post: 4616352"] Le 20 août 2008 à 22:25, Nick Brown a écrit : Don't ask me why (yet) but... a = cgi['a'].dup and... 22:47 fred@balvenie:~/> ruby test.rb (offline mode: enter name=value pairs on standard input) a=hi Inserting value a=bye into the database. What was actually inserted into the database: bye .... It seems that CGI does horrible, horrible things to its strings : require 'cgi' cgi = CGI.new('html4') a = cgi['a'] #.dup b = cgi['a'].dup puts "A :" a.sub!(/hi/, 'bye') puts a.to_s puts a.inspect puts a.class puts "B :" b.sub!(/hi/, 'bye') puts b.to_s puts b.inspect puts b.class Gives : 22:53 fred@balvenie:~> ruby test.rb (offline mode: enter name=value pairs on standard input) a=hi A : hi "bye" String B : bye "bye" String Ugh ! Fred [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
unintuitive language feature (exclamation functions)
Top