Skip to content

How to deal with nil? #363

Discussion options

You must be logged in to vote

The issue with my code is that I check the entire array for nil, instead of checking each item in the array. I should have checked if e is nil instead of data['Effect2'].

The following code does work and is cleaner:

png file: data['Effect2'].map { |t| t.nil? ? nil : "images/#{t.to_s.downcase}.png"}, x: 305, y: 800, width: :scale , height: 150

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LouisDeconinck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant