Ruby %w empty value -


how add empty string select option %w(mr ms mrs miss)?

i can ['', 'mr', 'ms', 'mrs', 'miss'] use %w. thx!

use unshift prepended object front:

=> %w(mr ms mrs miss).unshift "" #> ["", "mr", "ms", "mrs", "miss"] 

pretty version without brackets.

ok update:

=> %w(#{} mr ms mrs miss) #> ["", "mr", "ms", "mrs", "miss"] 

explain:

  • %w - allow interpolation
  • %w - not allow interpolation
  • #{} - empty string

Comments

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -