Skip to content

Instantly share code, notes, and snippets.

@EminenceHC
Created September 18, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EminenceHC/584afb87927b6e43c1a5 to your computer and use it in GitHub Desktop.
Save EminenceHC/584afb87927b6e43c1a5 to your computer and use it in GitHub Desktop.
ternary question
userJson = {
"student"=> {
"discharge_date" => "#{@discharge_date_time}" ? Date.strptime("#{@discharge_date_time}","%m/%d/%Y") : nil
}
@waseem
Copy link

waseem commented Sep 19, 2014

userJson = { "student" => { } }

if @discharge_date_time
  userJson["student"]["discharge_date"] = Date.strptime("#{@discharge_date_time}", "%m/%d/%Y")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment