Speed up development with full-stack environments for every branch.

Learn More

Say happy Valentines Day with a heart in Ruby [vday]

Forked from Basic Ruby Example.

99 Runs 110 Views 17 Copies

Tell that special someone happy Valentines Day in Ruby



AnandPatel 55

published 3 years ago

name = "Nancy";

l=->a,b=28,c=1{puts (("Love"*a).center(b))*c};

puts "\n    Happy Valentines Day";

# We need to center the name so add some whitespace logic here
whiteSpaceNeedTaken = 28-name.length;
# find out how much we need on each side
splitWhiteSpace = whiteSpaceNeedTaken/2;
leftSpace = splitWhiteSpace;
puts " " * leftSpace + name;
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).