Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
if (showAliasName && user.Job.Title != null && user.Job.Title.Trim().Length > 0) {
binding.Name = ? (user.AliasName != null
? user.AliasName + " " + user.Job.Title
: user.Name + " " + user.Job.Title)
} else {
binding.Name = "N/A";
}
// For you, what's the ideal conditional structure in this situation?
// Notes:
// Assume user.Job.Title comes from an outside system that we cannot control the format of (thus requiring the Trim)
binding.Name = showAliasName ? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.AliasName + " " + user.Job.Title : "N/A") : (user.Name != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.Name + " " + user.Job.Title : user.Name);
// Or
binding.Name = showAliasName
? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0
// For you, what's the ideal conditional structure in this situation?
// Notes:
// Assume user.Job.Title comes from an outside system that we cannot control the format of (thus requiring the Trim)
binding.Name = showAliasName ? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.AliasName + " " + user.Job.Title : "N/A") : (user.Name != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0 ? user.Name + " " + user.Job.Title : user.Name);
// Or
binding.Name = showAliasName
? (user.AliasName != null && user.Job.Title != null && user.Job.Title.Trim().Length > 0