Skip to content

Instantly share code, notes, and snippets.

@mokagio
Created March 5, 2021 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokagio/622e029f95e7dbb3d9cc31c6aa096a73 to your computer and use it in GitHub Desktop.
Save mokagio/622e029f95e7dbb3d9cc31c6aa096a73 to your computer and use it in GitHub Desktop.
Fastlane, Ruby, constants, and functions
#
# Proper version
#
WRAP_EMOJI = "🌯"
lane :test do |options|
UI.message wrap_in_emoji("Hello, World!")
end
def wrap_in_emoji(string)
"#{WRAP_EMOJI} #{string} #{WRAP_EMOJI}"
end
#
# Version that doesn't work because of variables vs constants in the scope of a
# function
#
# wrap_emoji = "🌯"
#
# lane :test do |options|
# UI.message wrap_in_emoji("Hello, World!")
# end
#
# def wrap_in_emoji(string)
# "#{wrap_emoji} #{string} #{wrap_emoji}"
# end
#
# Version that works because of instance variables, but that's not appropriate
# in this case because the value is not an instance variable
#
# @wrap_emoji = "🌯"
#
# lane :test do |options|
# UI.message wrap_in_emoji("Hello, World!")
# end
#
# def wrap_in_emoji(string)
# "#{@wrap_emoji} #{string} #{@wrap_emoji}"
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment