Ruby Examples
This commit is contained in:
19
level6/59.rb
Executable file
19
level6/59.rb
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/ruby
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
=begin
|
||||
snake_case → camelCase 변환
|
||||
=end
|
||||
|
||||
str = "hello_world"
|
||||
|
||||
puts str.split("_")
|
||||
.map { |s| s.capitalize}
|
||||
.join
|
||||
|
||||
# ---
|
||||
|
||||
x = str.gsub(/_[a-z]/) do |s|
|
||||
s.to_s.delete("_").upcase
|
||||
end
|
||||
puts x
|
||||
Reference in New Issue
Block a user